Java Code Examples for java.time.DayOfWeek#MONDAY

The following examples show how to use java.time.DayOfWeek#MONDAY . 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: TCKWeekFields.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="IsoWeekData")
Object[][] data_week() {
    return new Object[][] {
            {LocalDate.of(1969, 12, 29), DayOfWeek.MONDAY, 1, 1970},
            {LocalDate.of(2012, 12, 23), DayOfWeek.SUNDAY, 51, 2012},
            {LocalDate.of(2012, 12, 24), DayOfWeek.MONDAY, 52, 2012},
            {LocalDate.of(2012, 12, 27), DayOfWeek.THURSDAY, 52, 2012},
            {LocalDate.of(2012, 12, 28), DayOfWeek.FRIDAY, 52, 2012},
            {LocalDate.of(2012, 12, 29), DayOfWeek.SATURDAY, 52, 2012},
            {LocalDate.of(2012, 12, 30), DayOfWeek.SUNDAY, 52, 2012},
            {LocalDate.of(2012, 12, 31), DayOfWeek.MONDAY, 1, 2013},
            {LocalDate.of(2013, 1, 1), DayOfWeek.TUESDAY, 1, 2013},
            {LocalDate.of(2013, 1, 2), DayOfWeek.WEDNESDAY, 1, 2013},
            {LocalDate.of(2013, 1, 6), DayOfWeek.SUNDAY, 1, 2013},
            {LocalDate.of(2013, 1, 7), DayOfWeek.MONDAY, 2, 2013},
    };
}
 
Example 2
Source File: Utils.java    From schedge with MIT License 6 votes vote down vote up
public static DayOfWeek parseDayOfWeek(String dayOfWeek) {
  switch (dayOfWeek) {
  case "Mo":
    return DayOfWeek.MONDAY;
  case "Tu":
    return DayOfWeek.TUESDAY;
  case "We":
    return DayOfWeek.WEDNESDAY;
  case "Th":
    return DayOfWeek.THURSDAY;
  case "Fr":
    return DayOfWeek.FRIDAY;
  case "Sa":
    return DayOfWeek.SATURDAY;
  case "Su":
    return DayOfWeek.SUNDAY;
  default:
    return DayOfWeek.valueOf(dayOfWeek);
  }
}
 
Example 3
Source File: RelativeDate.java    From baleen with Apache License 2.0 6 votes vote down vote up
private void createRelativeWeek(
    TextBlock block, Integer charBegin, Integer charEnd, Integer weekOffset) {
  Temporal t = new Temporal(block.getJCas());
  block.setBeginAndEnd(t, charBegin, charEnd);

  t.setConfidence(1.0);
  t.setPrecision(PRECISION_RELATIVE);
  t.setScope(SCOPE_SINGLE);
  t.setTemporalType(TYPE_DATE);

  if (relativeTo != null && weekOffset != null) {
    LocalDate startOfWeek = relativeTo.plusWeeks(weekOffset);

    while (startOfWeek.getDayOfWeek() != DayOfWeek.MONDAY) {
      startOfWeek = startOfWeek.minusDays(1);
    }

    t.setTimestampStart(startOfWeek.atStartOfDay(ZoneOffset.UTC).toEpochSecond());

    LocalDate endOfWeek = startOfWeek.plusWeeks(1);
    t.setTimestampStop(endOfWeek.atStartOfDay(ZoneOffset.UTC).toEpochSecond());
  }

  addToJCasIndex(t);
}
 
Example 4
Source File: TCKLocalDate.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 5
Source File: FlipController.java    From tutorials with MIT License 5 votes vote down vote up
@RequestMapping(value = "/foo/{id}", method = RequestMethod.GET)
@FlipOnDaysOfWeek(daysOfWeek = {
    DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY,
    DayOfWeek.FRIDAY, DayOfWeek.SATURDAY, DayOfWeek.SUNDAY
})
public Foo getFooByNewId(@PathVariable int id) {
    return flipService.getFooById(id).orElse(new Foo("Not Found", -1));
}
 
Example 6
Source File: TimerChecker.java    From FX-AlgorithmTrading with MIT License 5 votes vote down vote up
private LocalDateTime culcurateNextDailyUpdate(LocalDate previousDate) {
    // 更新は火-土
    LocalDate nextDate = previousDate.plusDays(1);
    while (nextDate.getDayOfWeek() == DayOfWeek.SUNDAY || nextDate.getDayOfWeek() == DayOfWeek.MONDAY) {
        nextDate = nextDate.plusDays(1);
    }
    // 夏冬考慮
    return LocalDateTime.of(nextDate, MarketTimeUtility.getEODTime(nextDate));
}
 
Example 7
Source File: TCKLocalDate.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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 8
Source File: TestTextPrinter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="print_DayOfWeekData")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, expected text, input DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 9
Source File: TestTextParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="parseDayOfWeekText")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, input text, expected DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 10
Source File: TCKLocalDate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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 11
Source File: MarketTimeUtility.java    From FX-AlgorithmTrading with MIT License 5 votes vote down vote up
/**
 * 次の Market Open 時刻を取得します
 * @param jstDateTime
 * @return
 */
public static LocalDateTime getNextOpenTime(LocalDateTime jstDateTime) {
    // まずSummerで計算する
    LocalDateTime nextOpenTime = LocalDateTime.of(jstDateTime.getYear(), jstDateTime.getMonth(), jstDateTime.getDayOfMonth(),
            OPEN_WEEEK_MONDAY_SUMMER.getHour(), OPEN_WEEEK_MONDAY_SUMMER.getMinute());
    while (nextOpenTime.getDayOfWeek() != DayOfWeek.MONDAY) {
        nextOpenTime = nextOpenTime.plusDays(1);
    }
    // 日付が確定したら夏冬判定する
    if (isNYCSummer(nextOpenTime.toLocalDate())) {
        return nextOpenTime;
    } else {
        return nextOpenTime.withHour(OPEN_WEEEK_MONDAY_WINTER.getHour());
    }
}
 
Example 12
Source File: TCKLocalDate.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 13
Source File: WeeklyPlanningServiceImp.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
public DayOfWeek getFirstDayOfWeek() {
  WeeklyPlanning planning =
      Beans.get(UserService.class).getUserActiveCompany().getWeeklyPlanning();

  if (planning != null && ObjectUtils.notEmpty(planning.getWeekDays())) {
    Optional<DayPlanning> min =
        planning.getWeekDays().stream().min(Comparator.comparing(DayPlanning::getSequence));

    if (min.isPresent()) {
      return getDayOfWeek(min.get());
    }
  }

  return DayOfWeek.MONDAY;
}
 
Example 14
Source File: TCKLocalDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 15
Source File: TCKLocalDate.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 16
Source File: TimeSection.java    From OEE-Designer with MIT License 4 votes vote down vote up
public TimeSection(final LocalTime START, final LocalTime STOP, final String TEXT, final Color COLOR) {
    this(START, STOP, TEXT, null, COLOR, COLOR, Color.WHITE, false, DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
}
 
Example 17
Source File: TimeSection.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public TimeSection(final LocalTime START, final LocalTime STOP, final String TEXT, final Image ICON, final Color COLOR, final Color TEXT_COLOR) {
    this(START, STOP, TEXT, ICON, COLOR, COLOR, TEXT_COLOR, false, DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
}
 
Example 18
Source File: TimeSection.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public TimeSection(final LocalTime START, final LocalTime STOP, final Image ICON, final Color COLOR) {
    this(START, STOP, "", ICON, COLOR, COLOR, Color.WHITE, false, DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
}
 
Example 19
Source File: TCKDateTimeFormatter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name="formatWithZoneWithChronology")
Object[][] data_format_withZone_withChronology() {
    YearMonth ym = YearMonth.of(2008, 6);
    LocalDate ld = LocalDate.of(2008, 6, 30);
    LocalTime lt = LocalTime.of(11, 30);
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 11, 30);
    OffsetTime ot = OffsetTime.of(LocalTime.of(11, 30), OFFSET_PONE);
    OffsetDateTime odt = OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PONE);
    ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS);
    ChronoZonedDateTime<ThaiBuddhistDate> thaiZdt = ThaiBuddhistChronology.INSTANCE.zonedDateTime(zdt);
    Instant instant = Instant.ofEpochSecond(3600);
    return new Object[][] {
            {null, null, DayOfWeek.MONDAY, "::::"},
            {null, null, ym, "2008::::ISO"},
            {null, null, ld, "2008::::ISO"},
            {null, null, lt, ":11:::"},
            {null, null, ldt, "2008:11:::ISO"},
            {null, null, ot, ":11:+01:00::"},
            {null, null, odt, "2008:11:+01:00::ISO"},
            {null, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"},
            {null, null, instant, "::::"},

            {IsoChronology.INSTANCE, null, DayOfWeek.MONDAY, "::::ISO"},
            {IsoChronology.INSTANCE, null, ym, "2008::::ISO"},
            {IsoChronology.INSTANCE, null, ld, "2008::::ISO"},
            {IsoChronology.INSTANCE, null, lt, ":11:::ISO"},
            {IsoChronology.INSTANCE, null, ldt, "2008:11:::ISO"},
            {IsoChronology.INSTANCE, null, ot, ":11:+01:00::ISO"},
            {IsoChronology.INSTANCE, null, odt, "2008:11:+01:00::ISO"},
            {IsoChronology.INSTANCE, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"},
            {IsoChronology.INSTANCE, null, instant, "::::ISO"},

            {null, ZONE_PARIS, DayOfWeek.MONDAY, ":::Europe/Paris:"},
            {null, ZONE_PARIS, ym, "2008:::Europe/Paris:ISO"},
            {null, ZONE_PARIS, ld, "2008:::Europe/Paris:ISO"},
            {null, ZONE_PARIS, lt, ":11::Europe/Paris:"},
            {null, ZONE_PARIS, ldt, "2008:11::Europe/Paris:ISO"},
            {null, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:"},
            {null, ZONE_PARIS, odt, "2008:12:+02:00:Europe/Paris:ISO"},
            {null, ZONE_PARIS, zdt, "2008:11:+02:00:Europe/Paris:ISO"},
            {null, ZONE_PARIS, instant, "1970:02:+01:00:Europe/Paris:ISO"},

            {null, OFFSET_PTHREE, DayOfWeek.MONDAY, ":::+03:00:"},
            {null, OFFSET_PTHREE, ym, "2008:::+03:00:ISO"},
            {null, OFFSET_PTHREE, ld, "2008:::+03:00:ISO"},
            {null, OFFSET_PTHREE, lt, ":11::+03:00:"},
            {null, OFFSET_PTHREE, ldt, "2008:11::+03:00:ISO"},
            {null, OFFSET_PTHREE, ot, null},  // offset and zone clash
            {null, OFFSET_PTHREE, odt, "2008:13:+03:00:+03:00:ISO"},
            {null, OFFSET_PTHREE, zdt, "2008:12:+03:00:+03:00:ISO"},
            {null, OFFSET_PTHREE, instant, "1970:04:+03:00:+03:00:ISO"},

            {ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null},  // not a complete date
            {ThaiBuddhistChronology.INSTANCE, null, ym, null},  // not a complete date
            {ThaiBuddhistChronology.INSTANCE, null, ld, "2551::::ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, null, lt, ":11:::ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:::ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00::ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00::ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, null, instant, "::::ThaiBuddhist"},

            {ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null},  // not a complete date
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ym, null},  // not a complete date
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551:::Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11::Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11::Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist"},

            {null, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
            {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
            {IsoChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2008:11:+02:00:Europe/Paris:ISO"},
    };
}
 
Example 20
Source File: PackedLocalDateTime.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static boolean isMonday(long packedDateTime) {
  if (packedDateTime == missingValueIndicator()) return false;
  DayOfWeek dayOfWeek = getDayOfWeek(packedDateTime);
  return dayOfWeek == DayOfWeek.MONDAY;
}