Class TZInfo

java.lang.Object
org.deltava.beans.TZInfo
All Implemented Interfaces:
Serializable, Comparable<TZInfo>, ComboAlias, ViewEntry

public class TZInfo extends Object implements Serializable, ComboAlias, Comparable<TZInfo>, ViewEntry
A class for dealing with Time Zones.
Since:
1.0
Version:
11.0
Author:
Luke
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TZInfo
    Time Zone for GMT/UTC.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this Time Zone to another object by comparing the UTC offset.
    boolean
     
    static TZInfo
    get(String tzName)
    Gets a Time Zone wrapper using the standard Java Time Zone name.
    Returns the abbreviation of this Time Zone.
    Returns all initialized Time Zones.
    Returns the alias to use in the HTML <OPTION> element.
    Returns the visible name to use in the HTML <OPTION> element.
    Returns the JVM ID of the underlying Java TimeZone object.
    Returns this Time Zone's name.
    Returns the CSS class for this object if rendered in a view table.
    Returns the underlying Java TimeZone object.
    boolean
    Returns if this time zone observers Daylight Savings time at some point in the future.
    int
     
    static TZInfo
    init(String tzName, String displayName, String abbr)
    Creates a Time Zone Wrapper with user-provided name and abbreviation.
    protected static void
    Resets the list of time zones.
    Converts this time zone into a String.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • UTC

      public static final TZInfo UTC
      Time Zone for GMT/UTC.
  • Method Details

    • init

      public static TZInfo init(String tzName, String displayName, String abbr)
      Creates a Time Zone Wrapper with user-provided name and abbreviation.
      Parameters:
      tzName - A standard Java Time Zone ID
      displayName - If not null, the name to display instead of the JVM name
      abbr - An abbreviation for this time zone
      Returns:
      the TZInfo instance created
      See Also:
    • get

      public static TZInfo get(String tzName)
      Gets a Time Zone wrapper using the standard Java Time Zone name.
      Parameters:
      tzName - A standard Java Time Zone ID
      Returns:
      a TZInfo bean, or null if not found
      See Also:
    • getComboAlias

      public String getComboAlias()
      Description copied from interface: ComboAlias
      Returns the alias to use in the HTML <OPTION> element.
      Specified by:
      getComboAlias in interface ComboAlias
      Returns:
      The alias for this entry
    • getComboName

      public String getComboName()
      Description copied from interface: ComboAlias
      Returns the visible name to use in the HTML <OPTION> element.
      Specified by:
      getComboName in interface ComboAlias
      Returns:
      The visible name for this entry
    • getAll

      public static Collection<TZInfo> getAll()
      Returns all initialized Time Zones.
      Returns:
      a sorted Set of TZInfo objects
    • getZone

      public ZoneId getZone()
      Returns the underlying Java TimeZone object.
      Returns:
      The JVM time zone
    • getID

      public String getID()
      Returns the JVM ID of the underlying Java TimeZone object.
      Returns:
      The Java TimeZone ID
      See Also:
    • getAbbr

      public String getAbbr()
      Returns the abbreviation of this Time Zone.
      Returns:
      The user-supplied abbreviation, or null if none provided
    • getName

      public String getName()
      Returns this Time Zone's name.
      Returns:
      The name of the time zone; if no user-supplied name is present then use the Java name
    • hasDST

      public boolean hasDST()
      Returns if this time zone observers Daylight Savings time at some point in the future.
      Returns:
      TRUE if DST starts or ends at some future date, otherwise FALSE
    • toString

      public String toString()
      Converts this time zone into a String.
      Overrides:
      toString in class Object
      Returns:
      This displays name, UTC offset and DST usage in the following format:
      Name (ABBR) [GMT{+/-}hh:mm{/DST}]
    • compareTo

      public int compareTo(TZInfo tz2)
      Compares this Time Zone to another object by comparing the UTC offset.
      Specified by:
      compareTo in interface Comparable<TZInfo>
      Parameters:
      tz2 - the TimeZone entry to compare to
    • equals

      public boolean equals(Object o2)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • reset

      protected static void reset()
      Resets the list of time zones. For unit testing only.
    • getRowClassName

      public String getRowClassName()
      Description copied from interface: ViewEntry
      Returns the CSS class for this object if rendered in a view table.
      Specified by:
      getRowClassName in interface ViewEntry
      Returns:
      the CSS class name, or NULL if none