org.mulgara.util
Class Timezone

java.lang.Object
  extended by org.mulgara.util.Timezone

public class Timezone
extends Object

Maps from a known hour:minute offset for a timezone into a 6 bit code, and back. created Jun 5, 2008

Author:
Paul Gearon © 2008 Fedora Commons

Field Summary
static byte ZULU_CODE
          A special code for ZULU, to distinguish it from 00:00.
 
Constructor Summary
Timezone(byte code)
          Constructs a Timezone using a code.
Timezone(int hour, int minute)
          Constructs a Timezone using an hour:minute offset.
 
Method Summary
 TimeZone asJavaTimeZone()
          Convert to a TimeZone
 byte getCode()
          Gets the code for this timezone.
 int getHour()
          Gets the hour for this timezone.
 int getMinute()
          Gets the minute for this timezone.
static byte getZuluCode()
          Gets the code for the ZULU timezone.
 boolean isZulu()
          Indicates if this code represents Zulu.
static Timezone newZuluTimezone()
          A convenience factory method to construct a ZULU timezone.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZULU_CODE

public static final byte ZULU_CODE
A special code for ZULU, to distinguish it from 00:00. This is an external code, so the lowest 2 bits must be 0.

Constructor Detail

Timezone

public Timezone(byte code)
Constructs a Timezone using a code.

Parameters:
code - The code for a known timezone.
Throws:
IllegalArgumentException - The code does not correspond to a timezone in the database.

Timezone

public Timezone(int hour,
                int minute)
Constructs a Timezone using an hour:minute offset.

Parameters:
hour - The hour offset of the timezone. This cannot encode ZULU time.
minute - The minute offset of the timezone.
Throws:
IllegalArgumentException - The timezone is not in the database of known timezones.
Method Detail

newZuluTimezone

public static Timezone newZuluTimezone()
A convenience factory method to construct a ZULU timezone.

Returns:
a Timezone for ZULU time.

getHour

public int getHour()
Gets the hour for this timezone.


getMinute

public int getMinute()
Gets the minute for this timezone.


getCode

public byte getCode()
Gets the code for this timezone. This is guaranteed to use the top 5 bits, and set the bottom 2 to 0.


isZulu

public boolean isZulu()
Indicates if this code represents Zulu.


toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

asJavaTimeZone

public TimeZone asJavaTimeZone()
Convert to a TimeZone


getZuluCode

public static byte getZuluCode()
Gets the code for the ZULU timezone.



Copyright © 2011. All Rights Reserved.