Java Code Examples for org.threeten.bp.DayOfWeek#values()
The following examples show how to use
org.threeten.bp.DayOfWeek#values() .
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: TestTemporalAdjusters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 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: TestTemporalAdjusters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_previous() { 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.previous(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff < 0 && dayDiff > -8, dayDiff + " " + test); } else { assertSame(month, Month.JANUARY); assertTrue(date.getDayOfMonth() < 8); assertEquals(test.getYear(), 2006); assertSame(test.getMonth(), Month.DECEMBER); assertTrue(test.getDayOfMonth() > 24); } } } } }
Example 3
Source File: TzdbZoneRulesCompiler.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
private DayOfWeek parseDayOfWeek(String str) { str = str.toLowerCase(); for (DayOfWeek dow : DayOfWeek.values()) { if (matches(str, dow.name().toLowerCase())) { return dow; } } throw new IllegalArgumentException("Unknown day-of-week: " + str); }
Example 4
Source File: TestTemporalAdjusters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_nextOrSame() { 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 5
Source File: TestTemporalAdjusters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_previousOrSame() { 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); } } } } }