Package com.globalmentor.time
Class TimeZones
java.lang.Object
com.globalmentor.time.TimeZones
Constant values and utilities for working with time zones.
- Author:
- Garret Wilson
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic TimeZone
getTimeZone
(int utcOffsetHours, int utcOffsetMinutes) Retrieves a time zone based upon a UTC offset days and minutes for the given date.static TimeZone
getTimeZone
(Date date, int offset) Retrieves a time zone based upon a UTC offset for the given date.static TimeZone
getTimeZone
(Date date, int utcOffsetHours, int utcOffsetMinutes) Retrieves a time zone based upon a UTC offset days and minutes for the given date.
-
Field Details
-
GMT_ID
The ID for indicating the GMT zone. -
GMT
The shared time zone representing Greenwich Mean Time (GMT).- API Note:
- Modern time processing should use
UTC
instead.
-
UTC
The shared time zone representing Coordinated Universal Time (UTC).- API Note:
- This time zone is equivalent to
ZoneOffset.UTC
.
-
-
Constructor Details
-
TimeZones
public TimeZones()
-
-
Method Details
-
getTimeZone
Retrieves a time zone based upon a UTC offset for the given date. This method cannot return with certain a time zone valid for other dates, as sufficient information both as to location and to daylight saving is not provided. This method cannot handle offsets that do not fall on whole minutes.- Parameters:
date
- The date for which a time zone will be calculated.offset
- The UTC offset for which a time zone will be retrieved, in milliseconds.- Returns:
- A time zone appropriate for the given UTC offset for the given date.
- Throws:
NullPointerException
- if the given date isnull
.IllegalArgumentException
- if an offset was provided for which no time zone could be found.
-
getTimeZone
Retrieves a time zone based upon a UTC offset days and minutes for the given date. This method cannot return with certain a time zone valid for other dates, as sufficient information both as to location and to daylight saving is not provided.- Parameters:
date
- The date for which a time zone will be calculated.utcOffsetHours
- The UTC offset hours.utcOffsetMinutes
- The UTC offset minutes, or -1 if there is no UTC offset hours or minutes specified.- Returns:
- A time zone appropriate for the given UTC offset for the given date.
- Throws:
NullPointerException
- if the given date isnull
.IllegalArgumentException
- if an offset was provided for which no time zone could be found.
-
getTimeZone
Retrieves a time zone based upon a UTC offset days and minutes for the given date. This method cannot return with certain a time zone valid for other dates, as sufficient information both as to location and to daylight saving is not provided.- Parameters:
utcOffsetHours
- The UTC offset hours.utcOffsetMinutes
- The UTC offset minutes, or -1 if there is no UTC offset hours or minutes specified.- Returns:
- A general time zone appropriate for the given UTC offset.
- Throws:
IllegalArgumentException
- if an offset was provided for which no time zone could be found.
-