本文整理汇总了Java中java.time.DayOfWeek.values方法的典型用法代码示例。如果您正苦于以下问题:Java DayOfWeek.values方法的具体用法?Java DayOfWeek.values怎么用?Java DayOfWeek.values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.DayOfWeek
的用法示例。
在下文中一共展示了DayOfWeek.values方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWidget
import java.time.DayOfWeek; //导入方法依赖的package包/类
@PostConstruct
protected void initWidget() {
for (DayOfWeek day : DayOfWeek.values()) {
weekStart.addItem(day.toString());
}
// TODO: Make this more maintainable
templateDurationIndexMap = HashBiMap.create();
templateDuration.addItem("1 Week");
templateDurationIndexMap.put(1, 0);
templateDuration.addItem("2 Weeks");
templateDurationIndexMap.put(2, 1);
templateDuration.addItem("4 Weeks");
templateDurationIndexMap.put(4, 2);
desiredWeightInput.setValidators(new DecimalMinValidator<Integer>(0));
undesiredWeightInput.setValidators(new DecimalMinValidator<Integer>(0));
}
示例2: 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);
}
}
}
}
}
示例3: 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);
}
}
}
}
}
示例4: test_nextOrCurrent
import java.time.DayOfWeek; //导入方法依赖的package包/类
@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);
}
}
}
}
}
示例5: test_previousOrCurrent
import java.time.DayOfWeek; //导入方法依赖的package包/类
@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);
}
}
}
}
}
示例6: data_weekFields
import java.time.DayOfWeek; //导入方法依赖的package包/类
@DataProvider(name="weekFields")
Object[][] data_weekFields() {
Object[][] objects = new Object[49][];
int i = 0;
for (DayOfWeek firstDayOfWeek : DayOfWeek.values()) {
for (int minDays = 1; minDays <= 7; minDays++) {
objects[i++] = new Object[] {firstDayOfWeek, minDays};
}
}
return objects;
}
示例7: test_DayOfWeek_IsoChronology_vsCalendar
import java.time.DayOfWeek; //导入方法依赖的package包/类
@Test(dataProvider = "RangeVersusCalendar")
public void test_DayOfWeek_IsoChronology_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) {
GregorianCalendar cal = new GregorianCalendar();
assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type");
LocalDate isoDate = IsoChronology.INSTANCE.date(isoStartDate);
for (DayOfWeek firstDayOfWeek : DayOfWeek.values()) {
for (int minDays = 1; minDays <= 7; minDays++) {
WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays);
cal.setFirstDayOfWeek(Math.floorMod(firstDayOfWeek.getValue(), 7) + 1);
cal.setMinimalDaysInFirstWeek(minDays);
cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
cal.set(Calendar.YEAR, isoDate.get(YEAR));
cal.set(Calendar.MONTH, isoDate.get(MONTH_OF_YEAR) - 1);
cal.set(Calendar.DAY_OF_MONTH, isoDate.get(DAY_OF_MONTH));
// For every date in the range
while (isoDate.isBefore(isoEndDate)) {
assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal);
assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate);
assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate);
int jdow = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1;
int dow = isoDate.get(weekDef.dayOfWeek());
assertEquals(jdow, dow, "Calendar DayOfWeek does not match ISO DayOfWeek");
int jweekOfMonth = cal.get(Calendar.WEEK_OF_MONTH);
int isoWeekOfMonth = isoDate.get(weekDef.weekOfMonth());
assertEquals(jweekOfMonth, isoWeekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth");
int jweekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
int weekOfYear = isoDate.get(weekDef.weekOfWeekBasedYear());
assertEquals(jweekOfYear, weekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear");
int jWeekYear = cal.getWeekYear();
int weekBasedYear = isoDate.get(weekDef.weekBasedYear());
assertEquals(jWeekYear, weekBasedYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear");
int jweeksInWeekyear = cal.getWeeksInWeekYear();
int weeksInWeekBasedYear = (int)isoDate.range(weekDef.weekOfWeekBasedYear()).getMaximum();
assertEquals(jweeksInWeekyear, weeksInWeekBasedYear, "length of weekBasedYear");
isoDate = isoDate.plus(1, ChronoUnit.DAYS);
cal.add(Calendar.DAY_OF_MONTH, 1);
}
}
}
}