public class IllegalInstantException extends IllegalArgumentException
DateTime only store valid date-times.
One of the cases where validity is important is handling daylight savings time (DST).
In many places DST is used, where the local clock moves forward by an hour in spring and back by an hour in autumn/fall.
This means that in spring, there is a "gap" where a local time does not exist.
This exception refers to this gap, and it means that your application tried to create a date-time inside the gap - a time that did not exist. Since Joda-Time objects must be valid, this is not allowed.
Possible solutions may be as follows:
LocalDateTime, as all local date-times are valid.
When converting a
LocalDate to a
DateTime, then use
as this handles and manages any gaps.
When parsing, use
parseLocalDateTime() if the string being parsed has no time-zone.
|Constructor and Description|
|Modifier and Type||Method and Description|
Checks if the exception is, or has a cause, of
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public IllegalInstantException(String message)
message- the message
public IllegalInstantException(long instantLocal, String zoneId)
instantLocal- the local instant
zoneId- the time-zone ID, may be null
public static boolean isIllegalInstant(Throwable ex)
ex- the exception to check
Copyright © 2002–2017 Joda.org. All rights reserved.