@Test public void testBasic() { System.out.println(Year.now()); System.out.println(Year.of(2015)); System.out.println(Year.isLeap(2016)); Locale locale = Locale.getDefault(); System.out.println(Month.DECEMBER.getDisplayName(TextStyle.FULL, locale)); System.out.println(Month.DECEMBER.getDisplayName(TextStyle.SHORT, locale)); System.out.println(Month.DECEMBER.getDisplayName(TextStyle.NARROW, locale)); System.out.println(Month.DECEMBER.getDisplayName(TextStyle.FULL_STANDALONE, locale)); System.out.println(Month.of(8).ordinal()); System.out.println(Month.AUGUST.minus(2)); System.out.println(YearMonth.now()); System.out.println(MonthDay.now()); System.out.println(DayOfWeek.FRIDAY.plus(2)); System.out.println(DayOfWeek.of(1)); System.out.println( DayOfWeek.from(LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()))); System.out.println(Period.between(Year.now().atDay(1), LocalDate.now())); System.out.println(ChronoUnit.DAYS.between(Year.now().atDay(1), LocalDate.now())); }
public void test_weekOfMonth_buildDate_sun7() { // July 2011 starts on a Friday // Fri/Sat 1st/2nd are week 0 WeekRules wr = WeekRules.of(SUNDAY, 7); for (int i = 1; i <= 31; i++) { int w = MathUtils.floorDiv(i - 3, 7) + 1; int d = MathUtils.floorMod(i - 3, 7) + 1; CalendricalEngine engine = CalendricalEngine.merge( YearMonth.of(2011, JULY), wr.weekOfMonth().field(w), wr.dayOfWeek().field(d)); assertEquals(engine.derive(LocalDate.rule()), LocalDate.of(2011, JULY, i)); } }
public void test_getValue_Calendrical_yearMonth() { Calendrical cal = YearMonth.of(2007, 6); assertEquals(rule().getValue(cal), rule().field(2007)); }