下面列出了怎么用java.time.DateTimeException的API类实例代码及写法,或者点击链接到github查看源代码。
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
return new Object[][]{
{Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
{Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
{Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
{Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
{Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
{Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
{Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},
{Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},
};
}
@Test(dataProvider="Pivot")
public void test_pivot(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception {
try {
getFormatter0(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf);
if (result == null) {
fail("Expected exception");
}
assertEquals(buf.toString(), result);
} catch (DateTimeException ex) {
if (result == null || value < 0) {
assertEquals(ex.getMessage().contains(YEAR.toString()), true);
} else {
throw ex;
}
}
}
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
return new Object[][]{
{Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
{Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
{Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
{Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
{Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
{Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
{Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},
{Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},
};
}
@Test
public void test_factory_string_invalid() {
String[] values = new String[] {
"","A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T","U","V","W","X","Y","ZZ",
"0", "+0:00","+00:0","+0:0",
"+000","+00000",
"+0:00:00","+00:0:00","+00:00:0","+0:0:0","+0:0:00","+00:0:0","+0:00:0",
"1", "+01_00","+01;00","[email protected]","+01:AA",
"+19","+19:00","+18:01","+18:00:01","+1801","+180001",
"-0:00","-00:0","-0:0",
"-000","-00000",
"-0:00:00","-00:0:00","-00:00:0","-0:0:0","-0:0:00","-00:0:0","-0:00:0",
"-19","-19:00","-18:01","-18:00:01","-1801","-180001",
"-01_00","-01;00","[email protected]","-01:AA",
"@01:00",
};
for (int i = 0; i < values.length; i++) {
try {
ZoneOffset.of(values[i]);
fail("Should have failed:" + values[i]);
} catch (DateTimeException ex) {
// expected
}
}
}
@Test(dataProvider="Pivot")
public void test_pivot_baseDate(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception {
try {
getFormatterBaseDate(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf);
if (result == null) {
fail("Expected exception");
}
assertEquals(buf.toString(), result);
} catch (DateTimeException ex) {
if (result == null || value < 0) {
assertEquals(ex.getMessage().contains(YEAR.toString()), true);
} else {
throw ex;
}
}
}
/**
* Formats a date-time object to an {@code Appendable} using this formatter.
* <p>
* This outputs the formatted date-time to the specified destination.
* {@link Appendable} is a general purpose interface that is implemented by all
* key character output classes including {@code StringBuffer}, {@code StringBuilder},
* {@code PrintStream} and {@code Writer}.
* <p>
* Although {@code Appendable} methods throw an {@code IOException}, this method does not.
* Instead, any {@code IOException} is wrapped in a runtime exception.
*
* @param temporal the temporal object to format, not null
* @param appendable the appendable to format to, not null
* @throws DateTimeException if an error occurs during formatting
*/
public void formatTo(TemporalAccessor temporal, Appendable appendable) {
Objects.requireNonNull(temporal, "temporal");
Objects.requireNonNull(appendable, "appendable");
try {
DateTimePrintContext context = new DateTimePrintContext(temporal, this);
if (appendable instanceof StringBuilder) {
printerParser.format(context, (StringBuilder) appendable);
} else {
// buffer output to avoid writing to appendable in case of error
StringBuilder buf = new StringBuilder(32);
printerParser.format(context, buf);
appendable.append(buf);
}
} catch (IOException ex) {
throw new DateTimeException(ex.getMessage(), ex);
}
}
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
return new Object[][]{
{LocalTime.of(23, 5), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 0, 0), null},
{LocalTime.of(23, 5, 20), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 20, 0), null},
{LocalTime.of(23, 5, 20, 1000), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 20, 1000), null},
{LocalTime.of(23, 5, 20, 1000), LocalTime.MAX, LocalTime.of(23, 5, 20, 1000), null},
{LocalTime.of(23, 5, 20, 1000), LocalTime.MIN, LocalTime.of(23, 5, 20, 1000), null},
{LocalTime.of(23, 5, 20, 1000), LocalTime.NOON, LocalTime.of(23, 5, 20, 1000), null},
{LocalTime.of(23, 5, 20, 1000), LocalTime.MIDNIGHT, LocalTime.of(23, 5, 20, 1000), null},
{LocalTime.MAX, LocalTime.of(23, 5, 20, 1000), LocalTime.of(23, 59, 59, 999999999), null},
{LocalTime.MIN, LocalTime.of(23, 5, 20, 1000), LocalTime.of(0, 0, 0), null},
{LocalTime.NOON, LocalTime.of(23, 5, 20, 1000), LocalTime.of(12, 0, 0), null},
{LocalTime.MIDNIGHT, LocalTime.of(23, 5, 20, 1000), LocalTime.of(0, 0, 0), null},
{LocalTime.of(23, 5), LocalDateTime.of(2210, 2, 2, 1, 1), LocalDateTime.of(2210, 2, 2, 23, 5), null},
{LocalTime.of(23, 5), OffsetTime.of(1, 1, 0, 0, OFFSET_PTWO), OffsetTime.of(23, 5, 0, 0, OFFSET_PTWO), null},
{LocalTime.of(23, 5), OffsetDateTime.of(2210, 2, 2, 1, 1, 0, 0, OFFSET_PTWO), OffsetDateTime.of(2210, 2, 2, 23, 5, 0, 0, OFFSET_PTWO), null},
{LocalTime.of(23, 5), ZonedDateTime.of(2210, 2, 2, 1, 1, 0, 0, ZONE_PARIS), ZonedDateTime.of(2210, 2, 2, 23, 5, 0, 0, ZONE_PARIS), null},
{LocalTime.of(23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class},
{LocalTime.of(23, 5), null, null, NullPointerException.class},
};
}
@DataProvider(name="with")
Object[][] data_with() {
return new Object[][]{
{Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null},
{Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null},
{Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null},
{Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null},
{Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null},
{Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null},
{Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},
};
}
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
if (strict) {
LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
@Test
public void test_resolverFields_selectOneDateResolveYD() throws Exception {
DateTimeFormatter base = new DateTimeFormatterBuilder()
.appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-')
.appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter();
DateTimeFormatter f = base.withResolverFields(YEAR, DAY_OF_YEAR);
Set<TemporalField> expected = new HashSet<>(Arrays.asList(YEAR, DAY_OF_YEAR));
// Use set.equals(); testNG comparison of Collections is ordered
assertTrue(f.getResolverFields().equals(expected), "ResolveFields: " + f.getResolverFields());
try {
base.parse("2012-6-30-321", LocalDate::from); // wrong month/day-of-month
fail();
} catch (DateTimeException ex) {
// expected, fails as it produces two different dates
}
LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored month/day-of-month
assertEquals(parsed, LocalDate.of(2012, 11, 16));
}
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
if (e != null) {
fieldValues.put(ChronoField.ERA, (long) e);
}
if (yoe != null) {
fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
}
if (y != null) {
fieldValues.put(ChronoField.YEAR, (long) y);
}
if (field != null) {
LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(field), (Long) expected.longValue());
assertEquals(fieldValues.size(), 1);
} else {
try {
IsoChronology.INSTANCE.resolveDate(fieldValues, style);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, ThaiBuddhistDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (strict) {
ThaiBuddhistDate date = ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
ThaiBuddhistChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
private void updateCheckConflict(ChronoLocalDate cld) {
if (date != null) {
if (cld != null && date.equals(cld) == false) {
throw new DateTimeException("Conflict found: Fields resolved to two different dates: " + date + " " + cld);
}
} else if (cld != null) {
if (chrono.equals(cld.getChronology()) == false) {
throw new DateTimeException("ChronoLocalDate must use the effective parsed chronology: " + chrono);
}
date = cld;
}
}
ChronoLocalDate resolveYAA(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) {
int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR);
if (resolverStyle == ResolverStyle.LENIENT) {
long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
return dateYearDay(y, 1).plus(weeks, WEEKS).plus(days, DAYS);
}
int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR);
int ad = range(ALIGNED_DAY_OF_WEEK_IN_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), ALIGNED_DAY_OF_WEEK_IN_YEAR);
ChronoLocalDate date = dateYearDay(y, 1).plus((aw - 1) * 7 + (ad - 1), DAYS);
if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) {
throw new DateTimeException("Strict mode rejected resolved date as it is in a different year");
}
return date;
}
@DataProvider(name="signStyle")
Object[][] data_signStyle() {
return new Object[][] {
{LocalDate.of(0, 10, 2), SignStyle.ALWAYS, null, "+00"},
{LocalDate.of(2001, 10, 2), SignStyle.ALWAYS, null, "+2001"},
{LocalDate.of(-2001, 10, 2), SignStyle.ALWAYS, null, "-2001"},
{LocalDate.of(2001, 10, 2), SignStyle.NORMAL, null, "2001"},
{LocalDate.of(-2001, 10, 2), SignStyle.NORMAL, null, "-2001"},
{LocalDate.of(2001, 10, 2), SignStyle.NEVER, null, "2001"},
{LocalDate.of(-2001, 10, 2), SignStyle.NEVER, null, "2001"},
{LocalDate.of(2001, 10, 2), SignStyle.NOT_NEGATIVE, null, "2001"},
{LocalDate.of(-2001, 10, 2), SignStyle.NOT_NEGATIVE, DateTimeException.class, ""},
{LocalDate.of(0, 10, 2), SignStyle.EXCEEDS_PAD, null, "00"},
{LocalDate.of(1, 10, 2), SignStyle.EXCEEDS_PAD, null, "01"},
{LocalDate.of(-1, 10, 2), SignStyle.EXCEEDS_PAD, null, "-01"},
{LocalDate.of(20001, 10, 2), SignStyle.ALWAYS, DateTimeException.class, ""},
{LocalDate.of(20001, 10, 2), SignStyle.NORMAL, DateTimeException.class, ""},
{LocalDate.of(20001, 10, 2), SignStyle.NEVER, DateTimeException.class, ""},
{LocalDate.of(20001, 10, 2), SignStyle.EXCEEDS_PAD, DateTimeException.class, ""},
{LocalDate.of(20001, 10, 2), SignStyle.NOT_NEGATIVE, DateTimeException.class, ""},
};
}
@DataProvider(name="with_longTemporalField")
Object[][] data_with_longTemporalField() {
return new Object[][]{
{Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, 100, Instant.ofEpochSecond(100, 200), null},
{Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, 0, Instant.ofEpochSecond(0, 200), null},
{Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, -100, Instant.ofEpochSecond(-100, 200), null},
{Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 100, Instant.ofEpochSecond(10, 100), null},
{Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 0, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 100, Instant.ofEpochSecond(10, 100*1000), null},
{Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 0, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 100, Instant.ofEpochSecond(10, 100*1000*1000), null},
{Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 0, Instant.ofEpochSecond(10), null},
{Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 1000000000L, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 1000000, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 1000, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.SECOND_OF_MINUTE, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.SECOND_OF_DAY, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.OFFSET_SECONDS, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_DAY, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.MINUTE_OF_HOUR, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.MINUTE_OF_DAY, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_DAY, 1, null, DateTimeException.class},
{Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_DAY, 1, null, DateTimeException.class},
};
}
@Test
public void test_plus_longTemporalUnit_invalidUnit() {
for (TemporalUnit unit : INVALID_UNITS) {
try {
TEST_12_30_40_987654321.plus(1, unit);
fail("Unit should not be allowed " + unit);
} catch (DateTimeException ex) {
// expected
}
}
}
/**
* Gets the value of the specified field.
* <p>
* This will return the value for the specified field.
*
* @param field the field to find, not null
* @return the value, null if not found and optional is true
* @throws DateTimeException if the field is not available and the section is not optional
*/
Long getValue(TemporalField field) {
try {
return temporal.getLong(field);
} catch (DateTimeException ex) {
if (optional > 0) {
return null;
}
throw ex;
}
}
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) {
DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd");
TemporalAccessor temporal = f.parse("2010-06-30");
try {
function.apply(temporal);
fail("Should have failed");
} catch (DateTimeException ex) {
String msg = ex.getMessage();
assertTrue(msg.contains(expectedText), msg);
assertTrue(msg.contains("Year"), msg);
assertTrue(msg.contains("MinuteOfHour"), msg);
assertTrue(msg.contains("DayOfMonth"), msg);
}
}
/**
* Return the epoch day computed from Hijrah year, month, and day.
*
* @param prolepticYear the year to represent, 0-origin
* @param monthOfYear the month-of-year to represent, 1-origin
* @param dayOfMonth the day-of-month to represent, 1-origin
* @return the epoch day
*/
long getEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth) {
checkCalendarInit(); // ensure that the chronology is initialized
checkValidMonth(monthOfYear);
int epochMonth = yearToEpochMonth(prolepticYear) + (monthOfYear - 1);
if (epochMonth < 0 || epochMonth >= hijrahEpochMonthStartDays.length) {
throw new DateTimeException("Invalid Hijrah date, year: " +
prolepticYear + ", month: " + monthOfYear);
}
if (dayOfMonth < 1 || dayOfMonth > getMonthLength(prolepticYear, monthOfYear)) {
throw new DateTimeException("Invalid Hijrah day of month: " + dayOfMonth);
}
return epochMonthToEpochDay(epochMonth) + (dayOfMonth - 1);
}
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_tooSmall() {
ZoneOffset.ofHours(-19);
}
@Test(expectedExceptions=DateTimeException.class)
public void now_Clock_tooLow() {
Clock clock = Clock.fixed(MIN_INSTANT.minusNanos(1), ZoneOffset.UTC);
LocalDate.now(clock);
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_of_7ints_nanoTooLow() {
LocalDateTime.of(2007, 7, 15, 12, 30, 40, -1);
}
@Test(expectedExceptions={DateTimeException.class})
public void test_minusWeeks_invalidTooSmall() {
LocalDate.of(Year.MIN_VALUE, 1, 7).minusWeeks(1);
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_of_7ints_yearTooLow() {
LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30, 40, 987654321);
}
@Test(expectedExceptions=DateTimeException.class)
public void test_minusYears_int_invalidTooLarge() {
createDateMidnight(Year.MAX_VALUE, 1, 1).minusYears(-1);
}
@Test(expectedExceptions=DateTimeException.class)
public void test_minusDays_invalidTooLarge() {
createDateMidnight(Year.MAX_VALUE, 12, 31).minusDays(-1);
}
@Test(expectedExceptions=DateTimeException.class)
public void test_from_TemporalAccessor_invalid_noDerive() {
YearMonth.from(LocalTime.of(12, 30));
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_of_4intsMonth_yearTooLow() {
LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30);
}
@Test(expectedExceptions=DateTimeException.class)
public void factory_of_4intsMonth_dayTooHigh() {
LocalDateTime.of(2007, Month.JULY, 32, 12, 30);
}