Java 类java.time.DayOfWeek 实例源码

项目:openjdk-jdk10    文件:TCKTemporalAdjusters.java   
@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);
                }
            }
        }
    }
}
项目:jdk8u-jdk    文件:TCKWeekFields.java   
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWomDow_lenient(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField dowField = week.dayOfWeek();
    TemporalField womField = week.weekOfMonth();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(MONTH_OF_YEAR).appendLiteral(':')
                .appendValue(womField).appendLiteral(':')
                .appendValue(dowField).toFormatter().withResolverStyle(LENIENT);
        int wom = date.get(womField);
        int dow = date.get(dowField);
        for (int j = wom - 10; j < wom + 10; j++) {
            String str = date.getYear() + ":" + date.getMonthValue() + ":" + j + ":" + dow;
            LocalDate parsed = LocalDate.parse(str, f);
            assertEquals(parsed, date.plusWeeks(j - wom), " ::" + str + ": :" + i + "::" + j);
        }

        date = date.plusDays(1);
    }
}
项目:jdk8u-jdk    文件:TCKWeekFields.java   
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWomDow(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField dowField = week.dayOfWeek();
    TemporalField womField = week.weekOfMonth();

    for (int i = 1; i <= 15; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(MONTH_OF_YEAR).appendLiteral(':')
                .appendValue(womField).appendLiteral(':')
                .appendValue(dowField).toFormatter();
        String str = date.getYear() + ":" + date.getMonthValue() + ":" +
                date.get(womField) + ":" + date.get(dowField);
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, date, " :: " + str + " " + i);

        date = date.plusDays(1);
    }
}
项目:OpenJSharp    文件:ZoneOffsetTransitionRule.java   
/**
 * Creates an instance defining the yearly rule to create transitions between two offsets.
 *
 * @param month  the month of the month-day of the first day of the cutover week, not null
 * @param dayOfMonthIndicator  the day of the month-day of the cutover week, positive if the week is that
 *  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 *  from -28 to 31 excluding 0
 * @param dayOfWeek  the required day-of-week, null if the month-day should not be changed
 * @param time  the cutover time in the 'before' offset, not null
 * @param timeEndOfDay  whether the time is midnight at the end of day
 * @param timeDefnition  how to interpret the cutover
 * @param standardOffset  the standard offset in force at the cutover, not null
 * @param offsetBefore  the offset before the cutover, not null
 * @param offsetAfter  the offset after the cutover, not null
 * @throws IllegalArgumentException if the day of month indicator is invalid
 * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
 */
ZoneOffsetTransitionRule(
        Month month,
        int dayOfMonthIndicator,
        DayOfWeek dayOfWeek,
        LocalTime time,
        boolean timeEndOfDay,
        TimeDefinition timeDefnition,
        ZoneOffset standardOffset,
        ZoneOffset offsetBefore,
        ZoneOffset offsetAfter) {
    this.month = month;
    this.dom = (byte) dayOfMonthIndicator;
    this.dow = dayOfWeek;
    this.time = time;
    this.timeEndOfDay = timeEndOfDay;
    this.timeDefinition = timeDefnition;
    this.standardOffset = standardOffset;
    this.offsetBefore = offsetBefore;
    this.offsetAfter = offsetAfter;
}
项目:InfoSys-1D    文件:ProfCalendarController.java   
@GetMapping(value = "/prof/noti")
public String getProfNotifications(Model model) {
    try {
        LocalDate currDate = LocalDate.now();
        if (currDate.getDayOfWeek().equals(DayOfWeek.SATURDAY)
                || currDate.getDayOfWeek().equals(DayOfWeek.SUNDAY))
            currDate = currDate.plus(3, ChronoUnit.DAYS);

        LocalDate startDateOfSchoolWeek = currDate.with(DayOfWeek.MONDAY);

        String profEmail = authFacade.getAuthentication().getName();
        Professor prof = professorService.getProfessorByEmail(profEmail);

        List<BookingSlot> profBookings
                = bookingSlotService.getSlotsByProfAndSWeek(prof.getAlias(), startDateOfSchoolWeek);

        model.addAttribute("bookings", filterBookingSlots(profBookings));
        return "fragments/prof_noti";

    } catch (Exception ex) {
        ex.printStackTrace();

        model.addAttribute("message", ex.toString());
        return "error";
    }
}
项目:jdk8u-jdk    文件:TCKZoneOffsetTransitionRule.java   
@Test
public void test_toString_floatingWeekBackwards_last() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]");
}
项目:uroborosql    文件:DateTimeApiPropertyMapper.java   
@Override
public boolean canAccept(final Class<?> type) {
    return LocalDateTime.class.equals(type)
            || OffsetDateTime.class.equals(type)
            || ZonedDateTime.class.equals(type)
            || LocalDate.class.equals(type)
            || LocalTime.class.equals(type)
            || OffsetTime.class.equals(type)
            || Year.class.equals(type)
            || YearMonth.class.equals(type)
            || MonthDay.class.equals(type)
            || Month.class.equals(type)
            || DayOfWeek.class.equals(type)
            || checkEra(type)
            || checkChronoLocalDate(type);
}
项目:Chronetic    文件:ChronoDescriptorTest.java   
@Test
public void chronoDescriptorTest4() {
    ChronoSeries chronoSeries = testChronoSeries();
    ISeq<ChronoAllele> alleleSeq = ISeq.of(
            new ChronoFrequency(ChronoUnit.YEARS, 0, 1, 1, Instant.now()),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.HOURS), 0, 8),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.HOURS), 0, 9),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.HOURS), 0, 10),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.DAYS), 0, DayOfWeek.FRIDAY.getValue()),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.WEEKS), 0, 1),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.MONTHS), 0, Month.NOVEMBER.getValue()),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.YEARS), 0, 2011),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.YEARS), 0, 2012),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.YEARS), 0, 2013),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.YEARS), 0, 2014),
            new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.YEARS), 0, 2015)
    );

    ISeq<ChronoGene> geneSeq = ISeq.of(alleleSeq.map(ChronoGene::new));
    Chronosome chronosome = new Chronosome(geneSeq, chronoSeries);
    Chronotype chronotype = new Chronotype(chronoSeries, ISeq.of(Collections.singleton(chronosome)));

    String description = ChronoDescriptor.describe(chronotype).humanReadable();
    assertEquals("Expected equals",
            "Once a year from 2011 to 2015 on the first Friday of November between 8AM - 10AM", description);
}
项目:openjdk-jdk10    文件:ZoneOffsetTransitionRule.java   
/**
 * Creates an instance defining the yearly rule to create transitions between two offsets.
 *
 * @param month  the month of the month-day of the first day of the cutover week, not null
 * @param dayOfMonthIndicator  the day of the month-day of the cutover week, positive if the week is that
 *  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 *  from -28 to 31 excluding 0
 * @param dayOfWeek  the required day-of-week, null if the month-day should not be changed
 * @param time  the cutover time in the 'before' offset, not null
 * @param timeEndOfDay  whether the time is midnight at the end of day
 * @param timeDefnition  how to interpret the cutover
 * @param standardOffset  the standard offset in force at the cutover, not null
 * @param offsetBefore  the offset before the cutover, not null
 * @param offsetAfter  the offset after the cutover, not null
 * @throws IllegalArgumentException if the day of month indicator is invalid
 * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
 */
ZoneOffsetTransitionRule(
        Month month,
        int dayOfMonthIndicator,
        DayOfWeek dayOfWeek,
        LocalTime time,
        boolean timeEndOfDay,
        TimeDefinition timeDefnition,
        ZoneOffset standardOffset,
        ZoneOffset offsetBefore,
        ZoneOffset offsetAfter) {
    assert time.getNano() == 0;
    this.month = month;
    this.dom = (byte) dayOfMonthIndicator;
    this.dow = dayOfWeek;
    this.time = time;
    this.timeEndOfDay = timeEndOfDay;
    this.timeDefinition = timeDefnition;
    this.standardOffset = standardOffset;
    this.offsetBefore = offsetBefore;
    this.offsetAfter = offsetAfter;
}
项目:jdk8u-jdk    文件:TCKWeekFields.java   
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWom(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField womField = week.weekOfMonth();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(MONTH_OF_YEAR).appendLiteral(':')
                .appendValue(womField).appendLiteral(':')
                .appendValue(DAY_OF_WEEK).toFormatter().withResolverStyle(SMART);
        String str = date.getYear() + ":" + date.getMonthValue() + ":" +
                date.get(womField) + ":" + date.get(DAY_OF_WEEK);
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, date, " ::" + str + "::" + i);

        date = date.plusDays(1);
    }
}
项目:openjdk-jdk10    文件:TCKZoneRules.java   
public void test_London_getTransitionRules() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
    assertEquals(rules.size(), 2);

    ZoneOffsetTransitionRule in = rules.get(0);
    assertEquals(in.getMonth(), Month.MARCH);
    assertEquals(in.getDayOfMonthIndicator(), 25);  // optimized from -1
    assertEquals(in.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(in.getLocalTime(), LocalTime.of(1, 0));
    assertEquals(in.getTimeDefinition(), TimeDefinition.UTC);
    assertEquals(in.getStandardOffset(), OFFSET_ZERO);
    assertEquals(in.getOffsetBefore(), OFFSET_ZERO);
    assertEquals(in.getOffsetAfter(), OFFSET_PONE);

    ZoneOffsetTransitionRule out = rules.get(1);
    assertEquals(out.getMonth(), Month.OCTOBER);
    assertEquals(out.getDayOfMonthIndicator(), 25);  // optimized from -1
    assertEquals(out.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(out.getLocalTime(), LocalTime.of(1, 0));
    assertEquals(out.getTimeDefinition(), TimeDefinition.UTC);
    assertEquals(out.getStandardOffset(), OFFSET_ZERO);
    assertEquals(out.getOffsetBefore(), OFFSET_PONE);
    assertEquals(out.getOffsetAfter(), OFFSET_ZERO);
}
项目:jdk8u-jdk    文件:TCKWeekFields.java   
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWoy(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField woyField = week.weekOfYear();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(woyField).appendLiteral(':')
                .appendValue(DAY_OF_WEEK).toFormatter();
        String str = date.getYear() + ":" +
                date.get(woyField) + ":" + date.get(DAY_OF_WEEK);
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, date, " :: " + str + " " + i);

        date = date.plusDays(1);
    }
}
项目:openjdk-jdk10    文件:TCKWeekFields.java   
@Test(dataProvider="weekFields")
public void test_parse_resolve_localizedWoyDow(DayOfWeek firstDayOfWeek, int minDays) {
    LocalDate date = LocalDate.of(2012, 12, 15);
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    TemporalField dowField = week.dayOfWeek();
    TemporalField woyField = week.weekOfYear();

    for (int i = 1; i <= 60; i++) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(YEAR).appendLiteral(':')
                .appendValue(MONTH_OF_YEAR).appendLiteral(':')
                .appendValue(woyField).appendLiteral(':')
                .appendValue(dowField).toFormatter();
        String str = date.getYear() + ":" + date.getMonthValue() + ":" +
                date.get(woyField) + ":" + date.get(dowField);
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, date, " :: " + str + " " + i);

        date = date.plusDays(1);
    }
}
项目:jdk8u-jdk    文件:TCKTemporalAdjusters.java   
@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);
                }
            }
        }
    }
}
项目:jdk8u-jdk    文件:ZoneOffsetTransitionRule.java   
/**
 * Creates an instance defining the yearly rule to create transitions between two offsets.
 *
 * @param month  the month of the month-day of the first day of the cutover week, not null
 * @param dayOfMonthIndicator  the day of the month-day of the cutover week, positive if the week is that
 *  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 *  from -28 to 31 excluding 0
 * @param dayOfWeek  the required day-of-week, null if the month-day should not be changed
 * @param time  the cutover time in the 'before' offset, not null
 * @param timeEndOfDay  whether the time is midnight at the end of day
 * @param timeDefnition  how to interpret the cutover
 * @param standardOffset  the standard offset in force at the cutover, not null
 * @param offsetBefore  the offset before the cutover, not null
 * @param offsetAfter  the offset after the cutover, not null
 * @throws IllegalArgumentException if the day of month indicator is invalid
 * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
 */
ZoneOffsetTransitionRule(
        Month month,
        int dayOfMonthIndicator,
        DayOfWeek dayOfWeek,
        LocalTime time,
        boolean timeEndOfDay,
        TimeDefinition timeDefnition,
        ZoneOffset standardOffset,
        ZoneOffset offsetBefore,
        ZoneOffset offsetAfter) {
    this.month = month;
    this.dom = (byte) dayOfMonthIndicator;
    this.dow = dayOfWeek;
    this.time = time;
    this.timeEndOfDay = timeEndOfDay;
    this.timeDefinition = timeDefnition;
    this.standardOffset = standardOffset;
    this.offsetBefore = offsetBefore;
    this.offsetAfter = offsetAfter;
}
项目:morpheus-core    文件:ColumnTests.java   
@Test()
public void testSelectWithParallelProcessing() {
    final ZonedDateTime start = ZonedDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneId.of("GMT"));
    final ZonedDateTime end = start.plusMinutes(1000000);
    final Duration step = Duration.ofMinutes(1);
    final Index<ZonedDateTime> colKeys = Range.of(start, end, step).toIndex(ZonedDateTime.class);
    final DataFrame<String,ZonedDateTime> frame = DataFrame.of("C", colKeys, Double.class).applyDoubles(v -> Math.random() * 100);
    final long expectedCount = colKeys.keys().filter(t -> t.getDayOfWeek() == DayOfWeek.MONDAY).count();
    final DataFrame<String,ZonedDateTime> select1 = frame.cols().parallel().select(col -> col.key().getDayOfWeek() == DayOfWeek.MONDAY);
    final DataFrame<String,ZonedDateTime> select2 = frame.cols().sequential().select(col -> col.key().getDayOfWeek() == DayOfWeek.MONDAY);
    Assert.assertEquals(select1.colCount(), expectedCount, "Selection 1 has expected column count");
    Assert.assertEquals(select2.colCount(), expectedCount, "Selection 1 has expected column count");
    Assert.assertEquals(select1.rowCount(), 1, "Selection 1 has expected row count");
    Assert.assertEquals(select2.rowCount(), 1, "Selection 1 has expected row count");
    DataFrameAsserts.assertEqualsByIndex(select1, select2);
}
项目:InfoSys-1D    文件:StudentCalendarController.java   
@GetMapping(value = "/student/noti")
public String getStudentNotifications(Model model) {
    try {
        LocalDate currDate = LocalDate.now();
        if (currDate.getDayOfWeek().equals(DayOfWeek.SATURDAY)
                || currDate.getDayOfWeek().equals(DayOfWeek.SUNDAY))
            currDate = currDate.plus(3, ChronoUnit.DAYS);

        LocalDate startDateOfSchoolWeek = currDate.with(DayOfWeek.MONDAY);

        String studentEmail = authFacade.getAuthentication().getName();
        Student student = studentService.getStudentByEmail(studentEmail);

        List<BookingSlot> studentBookings
                = bookingSlotService.getSlotsByStudentAndSWeek(student.getId(), startDateOfSchoolWeek);

        model.addAttribute("bookings", filterStudentBookings(studentBookings));
        return "fragments/student_noti";

    } catch (Exception ex) {
        ex.printStackTrace();

        model.addAttribute("message", ex.toString());
        return "error";
    }
}
项目:outcomes    文件:Main.java   
public static void localDate() {

        LocalDate now = LocalDate.now();
        LocalDate plus = now.plus(1, ChronoUnit.DAYS);
        LocalDate minus = now.minusDays(1);

        System.out.println(now); //2017-09-20
        System.out.println(plus); //2017-09-21
        System.out.println(minus); //2017-09-19

        LocalDate customDate = LocalDate.of(2017, Month.SEPTEMBER, 20);
        DayOfWeek dayOfWeek = customDate.getDayOfWeek();
        System.out.println(dayOfWeek); //WEDNESDAY 星期三

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter
                .ofLocalizedDate(FormatStyle.MEDIUM)
                .withLocale(Locale.CHINA);
        LocalDate parse = LocalDate.parse("2017-09-20", dateTimeFormatter);
        System.out.println(parse); //2017-09-20
    }
项目:CalendarFX    文件:WeekFieldsViewSkin.java   
public WeekFieldsViewSkin(final WeekFieldsView view) {
    super(view);

    dayOfWeekComboBox = new ComboBox<>();
    dayOfWeekComboBox.getItems().addAll(DayOfWeek.values());
    dayOfWeekComboBox.setValue(view.getFirstDayOfWeek());

    minimalDaysInFirstWeekComboBox = new ComboBox<>();
    minimalDaysInFirstWeekComboBox.getItems().addAll(1, 2, 3, 4, 5, 6, 7);
    minimalDaysInFirstWeekComboBox.setValue(view.getMinimalDaysInFirstWeek());

    GridPane pane = new GridPane();
    pane.getStyleClass().add("content");
    pane.add(new Label("First day:"), 0, 0);
    pane.add(new Label("Minimum days:"), 0, 1);
    pane.add(dayOfWeekComboBox, 1, 0);
    pane.add(minimalDaysInFirstWeekComboBox, 1, 1);

    getChildren().add(pane);

    // listeners

    InvalidationListener updateListener = it -> updateValues();
    dayOfWeekComboBox.valueProperty().addListener(updateListener);
    minimalDaysInFirstWeekComboBox.valueProperty().addListener(updateListener);

    view.weekFieldsProperty().addListener(it -> {
        WeekFields fields = view.getWeekFields();
        dayOfWeekComboBox.setValue(fields.getFirstDayOfWeek());
        minimalDaysInFirstWeekComboBox.setValue(fields.getMinimalDaysInFirstWeek());
    });
}
项目:jdk8u-jdk    文件:TCKZoneOffsetTransitionRule.java   
@Test
public void test_getters_floatingWeek() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.getMonth(), Month.MARCH);
    assertEquals(test.getDayOfMonthIndicator(), 20);
    assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(test.getLocalTime(), TIME_0100);
    assertEquals(test.isMidnightEndOfDay(), false);
    assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
    assertEquals(test.getStandardOffset(), OFFSET_0200);
    assertEquals(test.getOffsetBefore(), OFFSET_0200);
    assertEquals(test.getOffsetAfter(), OFFSET_0300);
}
项目:openjdk-jdk10    文件:TCKTemporalAdjusters.java   
@Test(dataProvider = "dayOfWeekInMonth_zero")
public void test_dayOfWeekInMonth_zero(int year, int month, DayOfWeek dow, LocalDate expected) {
    for (int day = 1; day <= Month.of(month).length(false); day++) {
        LocalDate date = date(year, month, day);
        LocalDate test = (LocalDate) TemporalAdjusters.dayOfWeekInMonth(0, dow).adjustInto(date);
        assertEquals(test, expected);
    }
}
项目:openjdk-jdk10    文件:TCKZoneOffsetTransitionRule.java   
@Test
public void test_toString_floatingWeek_gap_notEndOfDay() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]");
}
项目:openjdk-jdk10    文件:TCKZoneOffsetTransitionRule.java   
@Test
public void test_createTransition_floatingWeekBackwards_seventhLast() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = ZoneOffsetTransition.of(
            LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
项目:jdk8u-jdk    文件:TCKZoneOffsetTransitionRule.java   
@Test
public void test_equals_monthDifferent() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
            Month.APRIL, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
}
项目:jdk8u-jdk    文件:TCKWeekFields.java   
@Test(dataProvider="IsoWeekData")
public void test_WOWBY(LocalDate date, DayOfWeek dow, int week, int wby) {
    WeekFields weekDef = WeekFields.ISO;
    TemporalField dowField = weekDef.dayOfWeek();
    TemporalField wowbyField = weekDef.weekOfWeekBasedYear();
    TemporalField yowbyField = weekDef.weekBasedYear();

    assertEquals(date.get(dowField), dow.getValue());
    assertEquals(date.get(wowbyField), week);
    assertEquals(date.get(yowbyField), wby);
}
项目:openjdk-jdk10    文件:TCKDayOfWeek.java   
@Test
public void test_adjustInto() {
    assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 2)), LocalDate.of(2012, 8, 27));
    assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 3)), LocalDate.of(2012, 9, 3));
    assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 4)), LocalDate.of(2012, 9, 3));
    assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 10)), LocalDate.of(2012, 9, 10));
    assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 11)), LocalDate.of(2012, 9, 10));
}
项目:persian-date-time    文件:PersianDateTest.java   
@Test
public void testOnGetDayOfWeek() {
    PersianDate saturday = PersianDate.of(1395, 11, 23);
    assertEquals(DayOfWeek.SATURDAY, saturday.getDayOfWeek());
    PersianDate sunday = PersianDate.of(1395, 11, 24);
    assertEquals(DayOfWeek.SUNDAY, sunday.getDayOfWeek());
    PersianDate monday = PersianDate.of(1395, 11, 25);
    assertEquals(DayOfWeek.MONDAY, monday.getDayOfWeek());
    PersianDate friday = PersianDate.of(1395, 11, 29);
    assertEquals(DayOfWeek.FRIDAY, friday.getDayOfWeek());
}
项目:uroborosql    文件:DateTimeApiParameterMapperTest.java   
@Test
public void testDayOfWeek() {
    DateTimeApiParameterMapper mapper = new DateTimeApiParameterMapper();
    assertThat(mapper.toJdbc(DayOfWeek.SUNDAY, null, null), instanceOf(Integer.class));
    assertThat(mapper.toJdbc(DayOfWeek.SUNDAY, null, null), is(7));
    assertThat(mapper.toJdbc(DayOfWeek.MONDAY, null, null), is(1));
}
项目:jdk8u-jdk    文件:TCKZoneOffsetTransitionRuleSerialization.java   
@Test
public void test_serialization_endOfDay() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.FRIDAY, LocalTime.MIDNIGHT, true, TimeDefinition.UTC,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertSerializable(test);
}
项目:openjdk-jdk10    文件:TestDateTimeFormatter.java   
@Test
public void test_parse_errorMessage() throws Exception {
    assertGoodErrorDate(DayOfWeek::from, "DayOfWeek");
    assertGoodErrorDate(Month::from, "Month");
    assertGoodErrorDate(YearMonth::from, "YearMonth");
    assertGoodErrorDate(MonthDay::from, "MonthDay");
    assertGoodErrorDate(LocalDate::from, "LocalDate");
    assertGoodErrorDate(LocalTime::from, "LocalTime");
    assertGoodErrorDate(LocalDateTime::from, "LocalDateTime");
    assertGoodErrorDate(OffsetTime::from, "OffsetTime");
    assertGoodErrorDate(OffsetDateTime::from, "OffsetDateTime");
    assertGoodErrorDate(ZonedDateTime::from, "ZonedDateTime");
    assertGoodErrorDate(Instant::from, "Instant");
    assertGoodErrorDate(ZoneOffset::from, "ZoneOffset");
    assertGoodErrorDate(ZoneId::from, "ZoneId");
    assertGoodErrorDate(ThaiBuddhistChronology.INSTANCE::date, "");

    assertGoodErrorTime(DayOfWeek::from, "DayOfWeek");
    assertGoodErrorTime(Month::from, "Month");
    assertGoodErrorTime(Year::from, "Year");
    assertGoodErrorTime(YearMonth::from, "YearMonth");
    assertGoodErrorTime(MonthDay::from, "MonthDay");
    assertGoodErrorTime(LocalDate::from, "LocalDate");
    assertGoodErrorTime(LocalTime::from, "LocalTime");
    assertGoodErrorTime(LocalDateTime::from, "LocalDateTime");
    assertGoodErrorTime(OffsetTime::from, "OffsetTime");
    assertGoodErrorTime(OffsetDateTime::from, "OffsetDateTime");
    assertGoodErrorTime(ZonedDateTime::from, "ZonedDateTime");
    assertGoodErrorTime(Instant::from, "Instant");
    assertGoodErrorTime(ZoneOffset::from, "ZoneOffset");
    assertGoodErrorTime(ZoneId::from, "ZoneId");
    assertGoodErrorTime(ThaiBuddhistChronology.INSTANCE::date, "");
}
项目:jdk8u-jdk    文件:WeekFields.java   
/**
 * Creates an instance of the definition.
 *
 * @param firstDayOfWeek  the first day of the week, not null
 * @param minimalDaysInFirstWeek  the minimal number of days in the first week, from 1 to 7
 * @throws IllegalArgumentException if the minimal days value is invalid
 */
private WeekFields(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) {
    Objects.requireNonNull(firstDayOfWeek, "firstDayOfWeek");
    if (minimalDaysInFirstWeek < 1 || minimalDaysInFirstWeek > 7) {
        throw new IllegalArgumentException("Minimal number of days is invalid");
    }
    this.firstDayOfWeek = firstDayOfWeek;
    this.minimalDays = minimalDaysInFirstWeek;
}
项目:openjdk-jdk10    文件:TCKWeekFields.java   
@Test(dataProvider="weekFields")
public void test_of_DayOfWeek_int_singleton(DayOfWeek firstDayOfWeek, int minDays) {
    WeekFields week = WeekFields.of(firstDayOfWeek, minDays);
    assertEquals(week.getFirstDayOfWeek(), firstDayOfWeek, "Incorrect firstDayOfWeek");
    assertEquals(week.getMinimalDaysInFirstWeek(), minDays, "Incorrect MinimalDaysInFirstWeek");
    assertSame(WeekFields.of(firstDayOfWeek, minDays), week);
}
项目:jdk8u-jdk    文件:TCKZoneOffsetTransitionRule.java   
@Test
public void test_equals_null_false() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(null), false);
}
项目:jdk8u-jdk    文件:TCKZoneOffsetTransitionRuleSerialization.java   
@Test
public void test_serialization_floatingWeekBackwards() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertSerializable(test);
}
项目:jdk8u-jdk    文件:TCKTemporalAdjusters.java   
@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);
                }
            }
        }
    }
}
项目:morpheus-core    文件:FilterTests.java   
@Test()
public void testRowIndexOfWithFilter() {
    final DataFrame<LocalDate,String> frame = createTestFrame1();
    final DataFrame<LocalDate,String> filter = frame.rows().select(row -> row.key().getDayOfWeek() == DayOfWeek.MONDAY);
    final List<LocalDate> dates = filter.rows().keys().collect(Collectors.toList());
    for (int i=0; i<dates.size(); ++i) {
        final LocalDate date = dates.get(i);
        final int rowIndex = filter.rows().ordinalOf(date, true);
        Assert.assertEquals(i, rowIndex, "Row index match");
    }
}
项目:openjdk-jdk10    文件:TestTextPrinter.java   
@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},
    };
}
项目:jdk8u-jdk    文件:TCKTemporalAdjusters.java   
@Test(dataProvider = "dayOfWeekInMonth_positive")
public void test_firstInMonth(int year, int month, DayOfWeek dow, LocalDate expected) {
    for (int day = 1; day <= Month.of(month).length(false); day++) {
        LocalDate date = date(year, month, day);
        LocalDate test = (LocalDate) TemporalAdjusters.firstInMonth(dow).adjustInto(date);
        assertEquals(test, expected, "day-of-month=" + day);
    }
}
项目:journey-planner    文件:PlanATrip.java   
@Override
public Task next(DayOfWeek departureDay) {
    return Task.where("{0} plans a journey between #departure and #destination, leaving around #departureTime next #departureDay",
            OpenApplication.onTheJourneyPlannerPage(),
            ChooseFromStation.of(departure),
            ChooseToStation.of(destination),
            ChooseTimeOfDeparture.of(departureTime).next(departureDay),
            Confirm.journeyDetails())
            .with("departure").of(departure)
            .with("destination").of(destination)
            .with("departureTime").of(departureTime)
            .with("departureDay").of(departureDay);
}
项目:openjdk-jdk10    文件:TestTextParserWithLocale.java   
@Test(dataProvider="parseDayOfWeekText")
public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) {
    DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale);
    ParsePosition pos = new ParsePosition(0);
    assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected);
    assertEquals(pos.getIndex(), input.length());
}