S - source type in other libraryT - target type in Time4Jpublic abstract class TemporalType<S,T>
extends java.lang.Object
Serves as bridge to temporal types of JDK or other date and time libraries.
All singleton instances are defined as static constants and are immutable.
| Modifier and Type | Field and Description |
|---|---|
static TemporalType<java.util.Date,Moment> |
JAVA_UTIL_DATE
Bridge between a traditional Java timestamp of type
java.util.Date and the class Moment. |
static TemporalType<java.lang.Long,Moment> |
MILLIS_SINCE_UNIX
Bridge between a traditional Java timestamp as count of milliseconds
since UNIX-epoch and the class
Moment. |
| Modifier and Type | Method and Description |
|---|---|
abstract S |
from(T time4j)
Converts the Time4J-type to an external type.
|
abstract T |
translate(S source)
Converts the external type to a type in Time4J.
|
public static final TemporalType<java.util.Date,Moment> JAVA_UTIL_DATE
Bridge between a traditional Java timestamp of type
java.util.Date and the class Moment.
The conversion does not take into account any UTC-leapseconds. The
supported value range is smaller than in the class Moment.
Example:
java.util.Date instant = new java.util.Date(86401 * 1000); Moment ut = TemporalType.JAVA_UTIL_DATE.translate(instant); System.out.println(ut); // output: 1970-01-02T00:00:01Z
public static final TemporalType<java.lang.Long,Moment> MILLIS_SINCE_UNIX
Bridge between a traditional Java timestamp as count of milliseconds
since UNIX-epoch and the class Moment.
The conversion does not take into account any UTC-leapseconds.
The supported value range is smaller than in the class Moment.
Example:
long instant = 86401 * 1000L; Moment ut = TemporalType.MILLIS_SINCE_UNIX.translate(instant); System.out.println(ut); // output: 1970-01-02T00:00:01Z
public abstract T translate(S source)
Converts the external type to a type in Time4J.
source - external objectjava.lang.ArithmeticException - in case of numerical overflowChronoException - if conversion failspublic abstract S from(T time4j)
Converts the Time4J-type to an external type.
time4j - Time4J-objectjava.lang.ArithmeticException - in case of numerical overflowChronoException - if conversion fails