public final class ZonalOffset extends Object implements Comparable<ZonalOffset>, TZID, Serializable
Represents the shift of a local timestamp relative to UTC timezone in seconds.
Following rule is the guideline (all data in seconds):
[Total Offset] = [Local Wall Time] - [POSIX Time]
| Modifier and Type | Class and Description |
|---|---|
static class |
ZonalOffset.Sign
Represents the sign of a zonal shift.
|
| Modifier and Type | Field and Description |
|---|---|
static ZonalOffset |
UTC
Constant for the UTC timezone representing a shift of
0 seconds
with the canonical representation "Z". |
| Modifier and Type | Method and Description |
|---|---|
static ZonalOffset |
atLongitude(BigDecimal longitude)
Creates a new shift based on a geographical longitude.
|
static ZonalOffset |
atLongitude(ZonalOffset.Sign sign,
int degrees,
int arcMinutes,
int arcSeconds)
Creates a new shift based on a geographical longitude.
|
String |
canonical()
Liefert eine kanonische Darstellung der Verschiebung.
|
int |
compareTo(ZonalOffset obj)
Compares the whole state with sign, hours, minutes, seconds and
fractional seconds in ascending order.
|
boolean |
equals(Object obj)
Compares the whole state.
|
int |
getAbsoluteHours()
Returns the hour part of this shift as absolute amount.
|
int |
getAbsoluteMinutes()
Returns the minute part of this shift as absolute amount.
|
int |
getAbsoluteSeconds()
Returns the second part of this shift as absolute amount.
|
int |
getFractionalAmount()
Returns the fractional second part of this shift in nanoseconds.
|
int |
getIntegralAmount()
Total shift in integer seconds without fractional part.
|
ZonalOffset.Sign |
getSign()
Return the sign of this zonal shift.
|
int |
hashCode()
Calculates the hash value.
|
static ZonalOffset |
ofHours(ZonalOffset.Sign sign,
int hours)
Static factory method for a shift which has the given full
hour part.
|
static ZonalOffset |
ofHoursMinutes(ZonalOffset.Sign sign,
int hours,
int minutes)
Static factory method for a shift which has given
hour and minute parts.
|
static ZonalOffset |
ofTotalSeconds(int total)
Creates a shift of the local time relative to UTC timezone
in integer seconds.
|
static ZonalOffset |
ofTotalSeconds(int total,
int fraction)
Creates a shift of the local time relative to UTC timezone
in integer seconds or fractional seconds.
|
String |
toString()
Returns a complete representation of this shift including
the sign.
|
public static final ZonalOffset UTC
Constant for the UTC timezone representing a shift of 0 seconds
with the canonical representation "Z".
public static ZonalOffset atLongitude(BigDecimal longitude)
Creates a new shift based on a geographical longitude.
longitude - geographical longitude in degrees defined in
range -180.0 <= longitude <= 180.0IllegalArgumentException - if range check failspublic static ZonalOffset atLongitude(ZonalOffset.Sign sign, int degrees, int arcMinutes, int arcSeconds)
Creates a new shift based on a geographical longitude.
sign - sign of shift relative to zero meridiandegrees - geographical length in degreed, defined in
range 0 <= degrees <= 180arcMinutes - arc minute part (0 <= arcMinutes <= 59)arcSeconds - arc second part (0 <= arcSeconds <= 59)IllegalArgumentException - if range check fails (also if total
absolute offset goes beyond 180 degrees)atLongitude(BigDecimal)public static ZonalOffset ofHours(ZonalOffset.Sign sign, int hours)
Static factory method for a shift which has the given full hour part.
Is equivalent to ofHoursMinutes(sign, hours, 0.
sign - sign of shift relative to zero meridianhours - hour part (0 <= hours <= 18)IllegalArgumentException - if range check failsofHoursMinutes(Sign, int, int)public static ZonalOffset ofHoursMinutes(ZonalOffset.Sign sign, int hours, int minutes)
Static factory method for a shift which has given hour and minute parts.
The given numerical values are identical to the numerical
parts of the canonical representation ±hh:mm".
The second part is always 0. Only values in the range
-18:00 <= [total-offset] <= +18:00 are allowed. When
calculating the total offset the sign relates to both hour
and minute part. Example: The expression
ZonalOffset.ofHoursMinutes(BEHIND_UTC, 4, 30) has the
representation -04:30 and a total shift in seconds of
-(4 * 3600 + 30 * 60) = 16200.
sign - sign ofHoursMinutes shift relative to zero meridianhours - hour part (0 <= hours <= 18)minutes - minute part (0 <= minutes <= 59)IllegalArgumentException - if range check failspublic static ZonalOffset ofTotalSeconds(int total)
Creates a shift of the local time relative to UTC timezone in integer seconds.
total - total shift in seconds defined in range
-18 * 3600 <= total <= 18 * 3600IllegalArgumentException - if range check failsgetIntegralAmount()public static ZonalOffset ofTotalSeconds(int total, int fraction)
Creates a shift of the local time relative to UTC timezone in integer seconds or fractional seconds.
total - total shift in seconds defined in range
-18 * 3600 <= total <= 18 * 3600fraction - fraction of secondIllegalArgumentException - if any arguments are out of range
or have different signsgetIntegralAmount(),
getFractionalAmount()public ZonalOffset.Sign getSign()
Return the sign of this zonal shift.
BEHIND_UTC if sign is negative else AHEAD_OF_UTCpublic int getAbsoluteHours()
Returns the hour part of this shift as absolute amount.
0 <= x <= 18getSign()public int getAbsoluteMinutes()
Returns the minute part of this shift as absolute amount.
0 <= x <= 59getSign()public int getAbsoluteSeconds()
Returns the second part of this shift as absolute amount.
0 <= x <= 59getSign()public int getIntegralAmount()
Total shift in integer seconds without fractional part.
-18 * 3600 <= x <= 18 * 3600getFractionalAmount()public int getFractionalAmount()
Returns the fractional second part of this shift in nanoseconds.
-999999999 <= x <= 999999999getIntegralAmount()public int compareTo(ZonalOffset obj)
Compares the whole state with sign, hours, minutes, seconds and fractional seconds in ascending order.
Shifts with sign west for Greenwich (behind UTC) are considered as smaller than shifts with sign east for Greenwich (ahead of UTC).
The natural order is consistent with equals().
compareTo in interface Comparable<ZonalOffset>public boolean equals(Object obj)
Compares the whole state.
public String toString()
Returns a complete representation of this shift including the sign.
If there are only full minutes or hours the representation is exactly as described in ISO-8601.
public String canonical()
Liefert eine kanonische Darstellung der Verschiebung.
Hinweis: Handelt es sich um die UTC-Zeitzone selbst, liefert die Methode die Darstellung "Z".
Copyright © 2014. All rights reserved.