S - source type in other libraryT - target type in Time4Jpublic abstract class TemporalType<S,T> extends Object implements Converter<S,T>
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<Calendar,ZonalDateTime> |
JAVA_UTIL_CALENDAR
Bridge between a traditional Java calendar of type
java.util.Calendar and the class ZonalDateTime. |
static TemporalType<Date,Moment> |
JAVA_UTIL_DATE
Bridge between a traditional Java timestamp of type
java.util.Date and the class Moment. |
static TemporalType<TimeZone,Timezone> |
JAVA_UTIL_TIMEZONE
Bridge between a traditional Java timezone of type
java.util.TimeZone and the class net.time4j.tz.Timezone. |
static TemporalType<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.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSourceTypepublic static final TemporalType<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<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 static final TemporalType<Calendar,ZonalDateTime> JAVA_UTIL_CALENDAR
Bridge between a traditional Java calendar of type
java.util.Calendar and the class ZonalDateTime.
The conversion tries to keep the instant and zone data involved. A change
of the local timestamp part of Calendar is possible, however. This
concerns the conversion of any non-gregorian calendar.
public static final TemporalType<TimeZone,Timezone> JAVA_UTIL_TIMEZONE
Bridge between a traditional Java timezone of type
java.util.TimeZone and the class net.time4j.tz.Timezone.
The conversion tries to keep the data and rules of the zone to be converted.
public abstract T translate(S source)
Converts the external type to a type in Time4J.
translate in interface Converter<S,T>source - external objectArithmeticException - in case of numerical overflowChronoException - if conversion failspublic abstract S from(T time4j)
Converts the Time4J-type to an external type.
from in interface Converter<S,T>time4j - Time4J-objectArithmeticException - in case of numerical overflowChronoException - if conversion failsCopyright © 2014–2018. All rights reserved.