下面列出了java.time.temporal.ChronoUnit#DECADES 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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},
};
}
@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},
};
}
@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},
};
}
@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},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] provider_factory_of_badTemporalUnit() {
return new Object[][] {
{0, MICROS},
{0, MILLIS},
{0, MINUTES},
{0, HOURS},
{0, HALF_DAYS},
{0, DAYS},
{0, ChronoUnit.MONTHS},
{0, ChronoUnit.YEARS},
{0, ChronoUnit.DECADES},
{0, ChronoUnit.CENTURIES},
{0, ChronoUnit.MILLENNIA},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] provider_factory_of_badTemporalUnit() {
return new Object[][] {
{0, MICROS},
{0, MILLIS},
{0, MINUTES},
{0, HOURS},
{0, HALF_DAYS},
{0, DAYS},
{0, ChronoUnit.MONTHS},
{0, ChronoUnit.YEARS},
{0, ChronoUnit.DECADES},
{0, ChronoUnit.CENTURIES},
{0, ChronoUnit.MILLENNIA},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] provider_factory_of_badTemporalUnit() {
return new Object[][] {
{0, MICROS},
{0, MILLIS},
{0, MINUTES},
{0, HOURS},
{0, HALF_DAYS},
{0, DAYS},
{0, ChronoUnit.MONTHS},
{0, ChronoUnit.YEARS},
{0, ChronoUnit.DECADES},
{0, ChronoUnit.CENTURIES},
{0, ChronoUnit.MILLENNIA},
};
}
@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},
};
}
@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},
};
}
@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},
};
}
@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},
};
}
@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},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] data_badTemporalUnit() {
return new Object[][] {
{ChronoUnit.MICROS},
{ChronoUnit.MILLIS},
{ChronoUnit.HALF_DAYS},
{ChronoUnit.DECADES},
{ChronoUnit.CENTURIES},
{ChronoUnit.MILLENNIA},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] data_badTemporalUnit() {
return new Object[][] {
{ChronoUnit.MICROS},
{ChronoUnit.MILLIS},
{ChronoUnit.HALF_DAYS},
{ChronoUnit.DECADES},
{ChronoUnit.CENTURIES},
{ChronoUnit.MILLENNIA},
};
}
@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},
};
}
@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},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] data_badTemporalUnit() {
return new Object[][] {
{ChronoUnit.MICROS},
{ChronoUnit.MILLIS},
{ChronoUnit.HALF_DAYS},
{ChronoUnit.DECADES},
{ChronoUnit.CENTURIES},
{ChronoUnit.MILLENNIA},
};
}
@DataProvider(name="BadTemporalUnit")
Object[][] data_badTemporalUnit() {
return new Object[][] {
{ChronoUnit.MICROS},
{ChronoUnit.MILLIS},
{ChronoUnit.HALF_DAYS},
{ChronoUnit.DECADES},
{ChronoUnit.CENTURIES},
{ChronoUnit.MILLENNIA},
};
}
/**
* Create and return a new TimePeriod representing exactly one decade.
*
* @return a new TimePeriod representing exactly one decade.
*/
public static TimePeriod oneDecade() {
return new TimePeriod(ChronoUnit.DECADES, 1);
}
/**
* Create and return a new TimePeriod representing one half of a century.
*
* @return a new TimePeriod representing one half of a century.
*/
public static TimePeriod halfCentury() {
return new TimePeriod(ChronoUnit.DECADES, 5);
}