本文整理汇总了Java中java.time.temporal.ChronoUnit.WEEKS属性的典型用法代码示例。如果您正苦于以下问题:Java ChronoUnit.WEEKS属性的具体用法?Java ChronoUnit.WEEKS怎么用?Java ChronoUnit.WEEKS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.time.temporal.ChronoUnit
的用法示例。
在下文中一共展示了ChronoUnit.WEEKS属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: data_plus_long_TemporalUnit
@DataProvider(name="plus_long_TemporalUnit")
Object[][] data_plus_long_TemporalUnit() {
return new Object[][] {
{Year.of(1), 1, ChronoUnit.YEARS, Year.of(2), null},
{Year.of(1), -12, ChronoUnit.YEARS, Year.of(-11), null},
{Year.of(1), 0, ChronoUnit.YEARS, Year.of(1), null},
{Year.of(999999999), 0, ChronoUnit.YEARS, Year.of(999999999), null},
{Year.of(-999999999), 0, ChronoUnit.YEARS, Year.of(-999999999), null},
{Year.of(0), -999999999, ChronoUnit.YEARS, Year.of(-999999999), null},
{Year.of(0), 999999999, ChronoUnit.YEARS, Year.of(999999999), null},
{Year.of(-1), 1, ChronoUnit.ERAS, Year.of(2), null},
{Year.of(5), 1, ChronoUnit.CENTURIES, Year.of(105), null},
{Year.of(5), 1, ChronoUnit.DECADES, Year.of(15), null},
{Year.of(999999999), 1, ChronoUnit.YEARS, null, DateTimeException.class},
{Year.of(-999999999), -1, ChronoUnit.YEARS, null, DateTimeException.class},
{Year.of(1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
{Year.of(1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
{Year.of(1), 0, ChronoUnit.MONTHS, null, DateTimeException.class},
};
}
示例2: data_minus_long_TemporalUnit
@DataProvider(name="minus_long_TemporalUnit")
Object[][] data_minus_long_TemporalUnit() {
return new Object[][] {
{Year.of(1), 1, ChronoUnit.YEARS, Year.of(0), null},
{Year.of(1), -12, ChronoUnit.YEARS, Year.of(13), null},
{Year.of(1), 0, ChronoUnit.YEARS, Year.of(1), null},
{Year.of(999999999), 0, ChronoUnit.YEARS, Year.of(999999999), null},
{Year.of(-999999999), 0, ChronoUnit.YEARS, Year.of(-999999999), null},
{Year.of(0), -999999999, ChronoUnit.YEARS, Year.of(999999999), null},
{Year.of(0), 999999999, ChronoUnit.YEARS, Year.of(-999999999), null},
{Year.of(999999999), 1, ChronoUnit.ERAS, Year.of(-999999999 + 1), null},
{Year.of(105), 1, ChronoUnit.CENTURIES, Year.of(5), null},
{Year.of(15), 1, ChronoUnit.DECADES, Year.of(5), null},
{Year.of(-999999999), 1, ChronoUnit.YEARS, null, DateTimeException.class},
{Year.of(1), -999999999, ChronoUnit.YEARS, null, DateTimeException.class},
{Year.of(1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
{Year.of(1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
{Year.of(1), 0, ChronoUnit.MONTHS, null, DateTimeException.class},
};
}
示例3: getParentChronoUnit
/**
* Returns the parent ChronoUnit for the given ChronoUnit.
*
* @param chronoUnit desired ChronoUnit
* @return parent ChronoUnit of the given ChronoUnit
*/
@NotNull
public static ChronoUnit getParentChronoUnit(@NotNull ChronoUnit chronoUnit) {
switch (requireNonNull(chronoUnit)) {
case NANOS:
return ChronoUnit.SECONDS;
case MICROS:
return ChronoUnit.SECONDS;
case MILLIS:
return ChronoUnit.SECONDS;
case SECONDS:
return ChronoUnit.MINUTES;
case MINUTES:
return ChronoUnit.HOURS;
case HOURS:
return ChronoUnit.DAYS;
case DAYS:
return ChronoUnit.WEEKS;
case WEEKS:
return ChronoUnit.MONTHS;
case MONTHS:
return ChronoUnit.YEARS;
case YEARS:
return ChronoUnit.DECADES;
case DECADES:
return ChronoUnit.CENTURIES;
case CENTURIES:
return ChronoUnit.ERAS;
default:
throw new UnsupportedOperationException("Unsupported chrono unit: " + chronoUnit);
}
}
示例4: getChildChronoUnit
/**
* Returns the child ChronoUnit for the given ChronoUnit.
*
* @param chronoUnit desired ChronoUnit
* @return child ChronoUnit of the given ChronoUnit
*/
@NotNull
public static ChronoUnit getChildChronoUnit(@NotNull ChronoUnit chronoUnit) {
switch (requireNonNull(chronoUnit)) {
case MICROS:
return ChronoUnit.NANOS;
case MILLIS:
return ChronoUnit.MICROS;
case SECONDS:
return ChronoUnit.MILLIS;
case MINUTES:
return ChronoUnit.SECONDS;
case HOURS:
return ChronoUnit.MINUTES;
case DAYS:
return ChronoUnit.HOURS;
case WEEKS:
return ChronoUnit.DAYS;
case MONTHS:
return ChronoUnit.WEEKS;
case YEARS:
return ChronoUnit.MONTHS;
case DECADES:
return ChronoUnit.YEARS;
case MILLENNIA:
return ChronoUnit.DECADES;
case ERAS:
return ChronoUnit.MILLENNIA;
default:
throw new UnsupportedOperationException("Unsupported chrono unit: " + chronoUnit);
}
}
示例5: data_plus_long_TemporalUnit
@DataProvider(name="plus_long_TemporalUnit")
Object[][] data_plus_long_TemporalUnit() {
return new Object[][] {
{YearMonth.of(1, 10), 1, ChronoUnit.YEARS, YearMonth.of(2, 10), null},
{YearMonth.of(1, 10), -12, ChronoUnit.YEARS, YearMonth.of(-11, 10), null},
{YearMonth.of(1, 10), 0, ChronoUnit.YEARS, YearMonth.of(1, 10), null},
{YearMonth.of(999999999, 12), 0, ChronoUnit.YEARS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-999999999, 1), 0, ChronoUnit.YEARS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(0, 1), -999999999, ChronoUnit.YEARS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(0, 12), 999999999, ChronoUnit.YEARS, YearMonth.of(999999999, 12), null},
{YearMonth.of(1, 10), 1, ChronoUnit.MONTHS, YearMonth.of(1, 11), null},
{YearMonth.of(1, 10), -12, ChronoUnit.MONTHS, YearMonth.of(0, 10), null},
{YearMonth.of(1, 10), 0, ChronoUnit.MONTHS, YearMonth.of(1, 10), null},
{YearMonth.of(999999999, 12), 0, ChronoUnit.MONTHS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-999999999, 1), 0, ChronoUnit.MONTHS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(-999999999, 2), -1, ChronoUnit.MONTHS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(999999999, 3), 9, ChronoUnit.MONTHS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-1, 10), 1, ChronoUnit.ERAS, YearMonth.of(2, 10), null},
{YearMonth.of(5, 10), 1, ChronoUnit.CENTURIES, YearMonth.of(105, 10), null},
{YearMonth.of(5, 10), 1, ChronoUnit.DECADES, YearMonth.of(15, 10), null},
{YearMonth.of(999999999, 12), 1, ChronoUnit.MONTHS, null, DateTimeException.class},
{YearMonth.of(-999999999, 1), -1, ChronoUnit.MONTHS, null, DateTimeException.class},
{YearMonth.of(1, 1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
{YearMonth.of(1, 1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
};
}
示例6: data_minus_long_TemporalUnit
@DataProvider(name="minus_long_TemporalUnit")
Object[][] data_minus_long_TemporalUnit() {
return new Object[][] {
{YearMonth.of(1, 10), 1, ChronoUnit.YEARS, YearMonth.of(0, 10), null},
{YearMonth.of(1, 10), 12, ChronoUnit.YEARS, YearMonth.of(-11, 10), null},
{YearMonth.of(1, 10), 0, ChronoUnit.YEARS, YearMonth.of(1, 10), null},
{YearMonth.of(999999999, 12), 0, ChronoUnit.YEARS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-999999999, 1), 0, ChronoUnit.YEARS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(0, 1), 999999999, ChronoUnit.YEARS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(0, 12), -999999999, ChronoUnit.YEARS, YearMonth.of(999999999, 12), null},
{YearMonth.of(1, 10), 1, ChronoUnit.MONTHS, YearMonth.of(1, 9), null},
{YearMonth.of(1, 10), 12, ChronoUnit.MONTHS, YearMonth.of(0, 10), null},
{YearMonth.of(1, 10), 0, ChronoUnit.MONTHS, YearMonth.of(1, 10), null},
{YearMonth.of(999999999, 12), 0, ChronoUnit.MONTHS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-999999999, 1), 0, ChronoUnit.MONTHS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(-999999999, 2), 1, ChronoUnit.MONTHS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(999999999, 11), -1, ChronoUnit.MONTHS, YearMonth.of(999999999, 12), null},
{YearMonth.of(1, 10), 1, ChronoUnit.ERAS, YearMonth.of(0, 10), null},
{YearMonth.of(5, 10), 1, ChronoUnit.CENTURIES, YearMonth.of(-95, 10), null},
{YearMonth.of(5, 10), 1, ChronoUnit.DECADES, YearMonth.of(-5, 10), null},
{YearMonth.of(999999999, 12), -1, ChronoUnit.MONTHS, null, DateTimeException.class},
{YearMonth.of(-999999999, 1), 1, ChronoUnit.MONTHS, null, DateTimeException.class},
{YearMonth.of(1, 1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
{YearMonth.of(1, 1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
};
}