Java Code Examples for java.time.Month#length()
The following examples show how to use
java.time.Month#length() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKTemporalAdjusters.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_next() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.next(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff > 0 && dayDiff < 8); } else { assertSame(month, Month.DECEMBER); assertTrue(date.getDayOfMonth() > 24); assertEquals(test.getYear(), 2008); assertSame(test.getMonth(), Month.JANUARY); assertTrue(test.getDayOfMonth() < 8); } } } } }
Example 2
Source File: TCKTemporalAdjusters.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_next() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.next(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff > 0 && dayDiff < 8); } else { assertSame(month, Month.DECEMBER); assertTrue(date.getDayOfMonth() > 24); assertEquals(test.getYear(), 2008); assertSame(test.getMonth(), Month.JANUARY); assertTrue(test.getDayOfMonth() < 8); } } } } }
Example 3
Source File: TCKTemporalAdjusters.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void test_next() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.next(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff > 0 && dayDiff < 8); } else { assertSame(month, Month.DECEMBER); assertTrue(date.getDayOfMonth() > 24); assertEquals(test.getYear(), 2008); assertSame(test.getMonth(), Month.JANUARY); assertTrue(test.getDayOfMonth() < 8); } } } } }
Example 4
Source File: TCKTemporalAdjusters.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_firstDayOfNextYear_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextYear().adjustInto(date); assertEquals(test.getYear(), 2009); assertEquals(test.getMonth(), JANUARY); assertEquals(test.getDayOfMonth(), 1); } } }
Example 5
Source File: TCKTemporalAdjusters.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_previousOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff <= 0 && dayDiff > -7); assertEquals(date.equals(test), date.getDayOfWeek() == dow); } else { assertFalse(date.getDayOfWeek() == dow); assertSame(month, Month.JANUARY); assertTrue(date.getDayOfMonth() < 7); assertEquals(test.getYear(), 2006); assertSame(test.getMonth(), Month.DECEMBER); assertTrue(test.getDayOfMonth() > 25); } } } } }
Example 6
Source File: TCKTemporalAdjusters.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test public void test_previousOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff <= 0 && dayDiff > -7); assertEquals(date.equals(test), date.getDayOfWeek() == dow); } else { assertFalse(date.getDayOfWeek() == dow); assertSame(month, Month.JANUARY); assertTrue(date.getDayOfMonth() < 7); assertEquals(test.getYear(), 2006); assertSame(test.getMonth(), Month.DECEMBER); assertTrue(test.getDayOfMonth() > 25); } } } } }
Example 7
Source File: TCKTemporalAdjusters.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_firstDayOfMonth_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); } } }
Example 8
Source File: TCKTemporalAdjusters.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_previousOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff <= 0 && dayDiff > -7); assertEquals(date.equals(test), date.getDayOfWeek() == dow); } else { assertFalse(date.getDayOfWeek() == dow); assertSame(month, Month.JANUARY); assertTrue(date.getDayOfMonth() < 7); assertEquals(test.getYear(), 2006); assertSame(test.getMonth(), Month.DECEMBER); assertTrue(test.getDayOfMonth() > 25); } } } } }
Example 9
Source File: TCKLocalDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void test_getDayOfWeek() { DayOfWeek dow = DayOfWeek.MONDAY; for (Month month : Month.values()) { int length = month.length(false); for (int i = 1; i <= length; i++) { LocalDateTime d = LocalDateTime.of(LocalDate.of(2007, month, i), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); assertSame(d.getDayOfWeek(), dow); dow = dow.plus(1); } } }
Example 10
Source File: TCKTemporalAdjusters.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_lastDayOfYear_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); } } }
Example 11
Source File: TCKLocalDate.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void test_getDayOfWeek() { DayOfWeek dow = DayOfWeek.MONDAY; for (Month month : Month.values()) { int length = month.length(false); for (int i = 1; i <= length; i++) { LocalDate d = LocalDate.of(2007, month, i); assertSame(d.getDayOfWeek(), dow); dow = dow.plus(1); } } }
Example 12
Source File: TCKTemporalAdjusters.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_firstDayOfMonth_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); } } }
Example 13
Source File: TCKTemporalAdjusters.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void test_firstDayOfMonth_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); } } }
Example 14
Source File: TCKTemporalAdjusters.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_previousOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff <= 0 && dayDiff > -7); assertEquals(date.equals(test), date.getDayOfWeek() == dow); } else { assertFalse(date.getDayOfWeek() == dow); assertSame(month, Month.JANUARY); assertTrue(date.getDayOfMonth() < 7); assertEquals(test.getYear(), 2006); assertSame(test.getMonth(), Month.DECEMBER); assertTrue(test.getDayOfMonth() > 25); } } } } }
Example 15
Source File: TCKTemporalAdjusters.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_lastDayOfMonth_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), month.length(true)); } } }
Example 16
Source File: TCKTemporalAdjusters.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_nextOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.nextOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff < 8); assertEquals(date.equals(test), date.getDayOfWeek() == dow); } else { assertFalse(date.getDayOfWeek() == dow); assertSame(month, Month.DECEMBER); assertTrue(date.getDayOfMonth() > 24); assertEquals(test.getYear(), 2008); assertSame(test.getMonth(), Month.JANUARY); assertTrue(test.getDayOfMonth() < 8); } } } } }
Example 17
Source File: TCKTemporalAdjusters.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_firstDayOfNextMonth_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextMonth().adjustInto(date); assertEquals(test.getYear(), month == DECEMBER ? 2008 : 2007); assertEquals(test.getMonth(), month.plus(1)); assertEquals(test.getDayOfMonth(), 1); } } }
Example 18
Source File: TCKTemporalAdjusters.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_lastDayOfMonth_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), month.length(false)); } } }
Example 19
Source File: TCKTemporalAdjusters.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_lastDayOfYear_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); } } }
Example 20
Source File: TCKTemporalAdjusters.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_firstDayOfNextYear_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextYear().adjustInto(date); assertEquals(test.getYear(), 2009); assertEquals(test.getMonth(), JANUARY); assertEquals(test.getDayOfMonth(), 1); } } }