Package com.globalmentor.time
Class TimeZones
- java.lang.Object
-
- com.globalmentor.time.TimeZones
-
public class TimeZones extends java.lang.Object
Constant values and utilities for working with time zones.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description TimeZones()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.TimeZone
getTimeZone(int utcOffsetHours, int utcOffsetMinutes)
Retrieves a time zone based upon a UTC offset days and minutes for the given date.static java.util.TimeZone
getTimeZone(java.util.Date date, int offset)
Retrieves a time zone based upon a UTC offset for the given date.static java.util.TimeZone
getTimeZone(java.util.Date date, int utcOffsetHours, int utcOffsetMinutes)
Retrieves a time zone based upon a UTC offset days and minutes for the given date.
-
-
-
Field Detail
-
GMT_ID
public static final java.lang.String GMT_ID
The ID for indicating the GMT zone.- See Also:
- Constant Field Values
-
GMT
public static final java.util.TimeZone GMT
The shared time zone representing Greenwich Mean Time (GMT).
-
-
Method Detail
-
getTimeZone
public static java.util.TimeZone getTimeZone(java.util.Date date, int offset)
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:
java.lang.NullPointerException
- if the given date isnull
.java.lang.IllegalArgumentException
- if an offset was provided for which no time zone could be found.
-
getTimeZone
public static java.util.TimeZone getTimeZone(java.util.Date date, int utcOffsetHours, int utcOffsetMinutes)
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:
java.lang.NullPointerException
- if the given date isnull
.java.lang.IllegalArgumentException
- if an offset was provided for which no time zone could be found.
-
getTimeZone
public static java.util.TimeZone getTimeZone(int utcOffsetHours, int utcOffsetMinutes)
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:
java.lang.IllegalArgumentException
- if an offset was provided for which no time zone could be found.
-
-