在上面的示例中,首先通过静态方法Year.now()获得当前年份,然后调用Year对象的minus(long, unit)方法,将要减去的数量1和时间单位ChronoUnit.YEARS传递给该方法,得到一个新的Year对象prevYear。 最后,将当前年份和上一年分别输出到控制台。 输出结果为: 当前年份:2021 上一年:2020 ...
Year:2019Aftersubtraction year:1999 方案二: // Java program to demonstrate// Year.minus(long, unit) methodimportjava.time.*;importjava.time.temporal.*;publicclassGFG{publicstaticvoidmain(String[]args){// create a Year objectYearyear=Year.of(2022);// print instanceSystem.out.println("Year :...
Year:2019 After subtraction year:1999 程序2: // Java program to demonstrate// Year.minus(long, unit) methodimportjava.time.*;importjava.time.temporal.*;publicclassGFG{publicstaticvoidmain(String[] args){// create a Year objectYear year = Year.of(2022);// print instanceSystem.out.println(...
publicYear minus(TemporalAmount amountToSubtract) Example The following example shows how to useminus. importjava.time.Period;importjava.time.Year;/*fromwww.java2s.com*/publicclassMain {publicstaticvoidmain(String[] args) { Year y = Year.of(2014); Year l = y.minus(Period.ofYears(12));...
YearMonth ZonedDateTime ZoneId ZoneOffset Java.Time.Chrono Java.Time.Format Java.Time.Temporal Java.Time.Zone Java.Util Java.Util.Concurrent Java.Util.Concurrent.Atomic Java.Util.Concurrent.Locks Java.Util.Functions Java.Util.Jar Java.Util.Logging ...
package com.tutorialspoint; import java.time.Period; import java.time.YearMonth; import java.time.temporal.ChronoField; public class YearMonthDemo { public static void main(String[] args) { YearMonth date = YearMonth.of(2017,12); System.out.println(date.get(ChronoField.MONTH_OF_YEAR)); Syste...
importjava.time.YearMonth;importjava.time.temporal.ChronoUnit;/*fromwww.java2s.com*/publicclassMain {publicstaticvoidmain(String[] args) { YearMonth y = YearMonth.now(); YearMonth s = y.minus(12,ChronoUnit.YEARS); System.out.println(s); ...
Year YearMonth ZonedDateTime ZoneId ZoneOffset Java.Time.Chrono Java.Time.Format Java.Time.Temporal Java.Time.Zone Java.Util Java.Util.Concurrent Java.Util.Concurrent.Atomic Java.Util.Concurrent.Locks Java.Util.Functions Java.Util.Jar Java.Util.Logging ...
minus(P3M), periodEnd, periodEnd, true, P3M); assertThat(ACT_ACT_ICMA.yearFraction(start, end, info)).isEqualTo((91d / (91d * 4d)) + (43d / (91d * 4d))); } Example 8Source File: DayCountTest.java From Strata with Apache License 2.0 5 votes @Test public void test_ac...
2.1.1740 Part 1 Section 22.6.2.76, YearAccessed (Year Accessed) 2.1.1741 Part 1 Section 22.8.2.1, ST_RelationshipId (Explicit Relationship ID) 2.1.1742 Part 1 Section 22.9.2.1, ST_CalendarType (Calendar Types) 2.1.1743 Part 1 Section 22.9.2.6, ST_Lang (Language Reference) 2.1...