@Immutable public class TimeZoneAdapter extends Object
Date, Date, Time, and
Timestamp objects to ZonedDateTime instances, where the time zone in which the temporal objects
were created by the database/driver can be adjusted.| Modifier and Type | Field and Description |
|---|---|
private static LocalDate |
EPOCH |
private ZoneId |
sqlDateZoneId |
private ZoneId |
sqlTimestampZoneId |
private ZoneId |
sqlTimeZoneId |
private ZoneId |
targetZoneId |
static ZoneId |
UTC |
private ZoneId |
utilDateZoneId |
| Modifier | Constructor and Description |
|---|---|
protected |
TimeZoneAdapter(ZoneId targetZoneId,
ZoneId utilDateZoneId,
ZoneId sqlDateZoneId,
ZoneId sqlTimeZoneId,
ZoneId sqlTimestampZoneId)
Create an adapter for temporal values defined in terms of the given zone.
|
| Modifier and Type | Method and Description |
|---|---|
static TimeZoneAdapter |
create()
Create a new adapter with UTC as the target zone and for a database that uses UTC for all temporal values.
|
static TimeZoneAdapter |
originatingIn(ZoneId zoneId)
Create a new adapter for a database that uses the specified zone for all temporal values.
|
static TimeZoneAdapter |
originatingInLocal()
Create a new adapter for a database that creates all temporal values in the local system time zone,
which is the same time zone used by
Calendar.getInstance(). |
static TimeZoneAdapter |
originatingInUtc()
Create a new adapter for a database that creates all temporal values in UTC.
|
protected ZoneId |
targetZoneId() |
ZonedDateTime |
toZonedDateTime(Date dbDate)
|
ZonedDateTime |
toZonedDateTime(Date dbDate)
Convert the specified database
Date to a date (at midnight) in the same time zone in which the
database created the value. |
ZonedDateTime |
toZonedDateTime(Time dbTime)
Convert the specified database
Time to a time (on the first epoch day) in the same time zone in which
the database created the value. |
ZonedDateTime |
toZonedDateTime(Timestamp dbTimestamp)
Convert the specified database
Timestamp to a timestamp in the same time zone in which
the database created the value. |
TimeZoneAdapter |
withLocalTargetZone()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for the target.
|
TimeZoneAdapter |
withLocalZoneForSqlDate()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Date temporal values. |
TimeZoneAdapter |
withLocalZoneForSqlTime()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Time temporal values. |
TimeZoneAdapter |
withLocalZoneForSqlTimestamp()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Timestamp temporal values. |
TimeZoneAdapter |
withLocalZoneForUtilDate()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Date temporal values. |
TimeZoneAdapter |
withTargetZone(ZoneId zoneId)
Create a new adapter that produces temporal values in the specified time zone.
|
TimeZoneAdapter |
withUtcTargetZone()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for the target.
|
TimeZoneAdapter |
withUtcZoneForSqlDate()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Date temporal values. |
TimeZoneAdapter |
withUtcZoneForSqlTime()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Time temporal values. |
TimeZoneAdapter |
withUtcZoneForSqlTimestamp()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Timestamp temporal values. |
TimeZoneAdapter |
withUtcZoneForUtilDate()
Create a new adapter for a database that uses the same time zones as this adapter except it uses the UTC
zone for
Date temporal values. |
TimeZoneAdapter |
withZoneForAll(ZoneId zoneId)
Create a new adapter for a database that uses the specified zone for all temporal values and this adapter's target zone.
|
TimeZoneAdapter |
withZoneForSqlDate(ZoneId zoneId)
Create a new adapter for a database that uses the same time zones as this adapter except it uses the specified
zone for
Date temporal values. |
TimeZoneAdapter |
withZoneForSqlTime(ZoneId zoneId)
Create a new adapter for a database that uses the same time zones as this adapter except it uses the specified
zone for
Time temporal values. |
TimeZoneAdapter |
withZoneForSqlTimestamp(ZoneId zoneId)
Create a new adapter for a database that uses the same time zones as this adapter except it uses the specified
zone for
Timestamp temporal values. |
TimeZoneAdapter |
withZoneForUtilDate(ZoneId zoneId)
Create a new adapter for a database that uses the same time zones as this adapter except it uses the specified
zone for
Date temporal values. |
private static final LocalDate EPOCH
public static final ZoneId UTC
private final ZoneId targetZoneId
private final ZoneId utilDateZoneId
private final ZoneId sqlDateZoneId
private final ZoneId sqlTimeZoneId
private final ZoneId sqlTimestampZoneId
protected TimeZoneAdapter(ZoneId targetZoneId, ZoneId utilDateZoneId, ZoneId sqlDateZoneId, ZoneId sqlTimeZoneId, ZoneId sqlTimestampZoneId)
targetZoneId - the zone in which the output temporal values are defined; may not be nullutilDateZoneId - the zone in which Date values are defined; may not be nullsqlDateZoneId - the zone in which Date values are defined; may not be nullsqlTimeZoneId - the zone in which Time values are defined; may not be nullsqlTimestampZoneId - the zone in which Timestamp values are defined; may not be nullpublic static TimeZoneAdapter create()
public static TimeZoneAdapter originatingIn(ZoneId zoneId)
zoneId - the zone in which all temporal values are created by the database; may not be nullpublic static TimeZoneAdapter originatingInUtc()
public static TimeZoneAdapter originatingInLocal()
Calendar.getInstance().protected ZoneId targetZoneId()
public ZonedDateTime toZonedDateTime(Date dbDate)
Date, Date, Time, or
Timestamp objects to a date and time in the same time zone in which the database created the
value. If only time information is provided in the input value, the date information will
be set to the first day of the epoch. If only date information is provided in the input
value, the time information will be at midnight on the specified day.dbDate - the database-generated value; may not be nullpublic ZonedDateTime toZonedDateTime(Date dbDate)
Date to a date (at midnight) in the same time zone in which the
database created the value.dbDate - the database-generated value; may not be nullpublic ZonedDateTime toZonedDateTime(Time dbTime)
Time to a time (on the first epoch day) in the same time zone in which
the database created the value.dbTime - the database-generated value; may not be nullpublic ZonedDateTime toZonedDateTime(Timestamp dbTimestamp)
Timestamp to a timestamp in the same time zone in which
the database created the value.dbTimestamp - the database-generated value; may not be nullpublic TimeZoneAdapter withTargetZone(ZoneId zoneId)
zoneId - the zone in which all temporal values are to be defined; may not be nullpublic TimeZoneAdapter withZoneForAll(ZoneId zoneId)
zoneId - the zone in which all temporal values are created by the database; may not be nullpublic TimeZoneAdapter withZoneForUtilDate(ZoneId zoneId)
Date temporal values.zoneId - the zone in which all Date values are created by the database; may not be nullpublic TimeZoneAdapter withZoneForSqlDate(ZoneId zoneId)
Date temporal values.zoneId - the zone in which all Date values are created by the database; may not be nullpublic TimeZoneAdapter withZoneForSqlTime(ZoneId zoneId)
Time temporal values.zoneId - the zone in which all Time values are created by the database; may not be nullpublic TimeZoneAdapter withZoneForSqlTimestamp(ZoneId zoneId)
Timestamp temporal values.zoneId - the zone in which all Timestamp values are created by the database; may not be nullpublic TimeZoneAdapter withUtcTargetZone()
public TimeZoneAdapter withUtcZoneForUtilDate()
Date temporal values.public TimeZoneAdapter withUtcZoneForSqlDate()
Date temporal values.public TimeZoneAdapter withUtcZoneForSqlTime()
Time temporal values.public TimeZoneAdapter withUtcZoneForSqlTimestamp()
Timestamp temporal values.public TimeZoneAdapter withLocalTargetZone()
public TimeZoneAdapter withLocalZoneForUtilDate()
Date temporal values.public TimeZoneAdapter withLocalZoneForSqlDate()
Date temporal values.public TimeZoneAdapter withLocalZoneForSqlTime()
Time temporal values.public TimeZoneAdapter withLocalZoneForSqlTimestamp()
Timestamp temporal values.Copyright © 2016 JBoss by Red Hat. All rights reserved.