Class IllegalInstantException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.IllegalArgumentException
-
- org.joda.time.IllegalInstantException
-
- All Implemented Interfaces:
java.io.Serializable
public class IllegalInstantException extends java.lang.IllegalArgumentExceptionException thrown when attempting to create an instant or date-time that cannot exist.Classes like
DateTimeonly 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:
UseLocalDateTime, as all local date-times are valid.
When converting aLocalDateto aDateTime, then usetoDateTimeAsStartOfDay()as this handles and manages any gaps.
When parsing, useparseLocalDateTime()if the string being parsed has no time-zone.- Since:
- 2.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDSerialization lock.
-
Constructor Summary
Constructors Constructor Description IllegalInstantException(long instantLocal, java.lang.String zoneId)Constructor.IllegalInstantException(java.lang.String message)Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringcreateMessage(long instantLocal, java.lang.String zoneId)static booleanisIllegalInstant(java.lang.Throwable ex)Checks if the exception is, or has a cause, ofIllegalInstantException.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serialization lock.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IllegalInstantException
public IllegalInstantException(java.lang.String message)
Constructor.- Parameters:
message- the message
-
IllegalInstantException
public IllegalInstantException(long instantLocal, java.lang.String zoneId)Constructor.- Parameters:
instantLocal- the local instantzoneId- the time-zone ID, may be null
-
-
Method Detail
-
createMessage
private static java.lang.String createMessage(long instantLocal, java.lang.String zoneId)
-
isIllegalInstant
public static boolean isIllegalInstant(java.lang.Throwable ex)
Checks if the exception is, or has a cause, ofIllegalInstantException.- Parameters:
ex- the exception to check- Returns:
- true if an
IllegalInstantException
-
-