当前位置: 首页>>代码示例>>Java>>正文


Java DayOfWeek类代码示例

本文整理汇总了Java中java.time.DayOfWeek的典型用法代码示例。如果您正苦于以下问题:Java DayOfWeek类的具体用法?Java DayOfWeek怎么用?Java DayOfWeek使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DayOfWeek类属于java.time包,在下文中一共展示了DayOfWeek类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canAccept

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:17,代码来源:DateTimeApiPropertyMapper.java

示例2: WeekFieldsViewSkin

import java.time.DayOfWeek; //导入依赖的package包/类
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());
    });
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:33,代码来源:WeekFieldsViewSkin.java

示例3: test_next

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TCKTemporalAdjusters.java

示例4: test_parse_resolve_localizedWomDow_lenient

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:TCKWeekFields.java

示例5: test_parse_resolve_localizedWomDow

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:TCKWeekFields.java

示例6: ZoneOffsetTransitionRule

import java.time.DayOfWeek; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:ZoneOffsetTransitionRule.java

示例7: getProfNotifications

import java.time.DayOfWeek; //导入依赖的package包/类
@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";
    }
}
 
开发者ID:ericywl,项目名称:InfoSys-1D,代码行数:27,代码来源:ProfCalendarController.java

示例8: test_toString_floatingWeekBackwards_last

import java.time.DayOfWeek; //导入依赖的package包/类
@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]");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKZoneOffsetTransitionRule.java

示例9: chronoDescriptorTest4

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
}
 
开发者ID:BFergerson,项目名称:Chronetic,代码行数:27,代码来源:ChronoDescriptorTest.java

示例10: ZoneOffsetTransitionRule

import java.time.DayOfWeek; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:ZoneOffsetTransitionRule.java

示例11: test_parse_resolve_localizedWom

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TCKWeekFields.java

示例12: test_London_getTransitionRules

import java.time.DayOfWeek; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TCKZoneRules.java

示例13: test_parse_resolve_localizedWoy

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKWeekFields.java

示例14: test_parse_resolve_localizedWoyDow

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:TCKWeekFields.java

示例15: test_previous

import java.time.DayOfWeek; //导入依赖的package包/类
@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);
                }
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:TCKTemporalAdjusters.java


注:本文中的java.time.DayOfWeek类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。