ezvcard.util
Class UtcOffset

java.lang.Object
  extended by ezvcard.util.UtcOffset

public final class UtcOffset
extends Object

Represents a UTC offset.

Author:
Michael Angstadt

Constructor Summary
UtcOffset(int hour, int minute)
          Creates a new UTC offset.
 
Method Summary
 boolean equals(Object obj)
           
 int getHour()
          Gets the hour component.
 int getMinute()
          Gets the minute component.
 int hashCode()
           
static UtcOffset parse(String text)
          Parses a UTC offset from a string.
static UtcOffset parse(TimeZone timezone)
          Creates a UTC offset from a TimeZone object.
 String toString()
          Converts this offset to its ISO string representation using "basic" format.
 String toString(boolean extended)
          Converts this offset to its ISO string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UtcOffset

public UtcOffset(int hour,
                 int minute)
Creates a new UTC offset.

Parameters:
hour - the hour component (may be negative)
minute - the minute component (must be between 0 and 59)
Method Detail

parse

public static UtcOffset parse(String text)
Parses a UTC offset from a string.

Parameters:
text - the text to parse (e.g. "-0500")
Returns:
the parsed UTC offset
Throws:
IllegalArgumentException - if the text cannot be parsed

parse

public static UtcOffset parse(TimeZone timezone)
Creates a UTC offset from a TimeZone object.

Parameters:
timezone - the timezone
Returns:
the UTC offset

getHour

public int getHour()
Gets the hour component.

Returns:
the hour component

getMinute

public int getMinute()
Gets the minute component.

Returns:
the minute component

toString

public String toString()
Converts this offset to its ISO string representation using "basic" format.

Overrides:
toString in class Object
Returns:
the ISO string representation (e.g. "-0500")

toString

public String toString(boolean extended)
Converts this offset to its ISO string representation.

Parameters:
extended - true to use extended format (e.g. "-05:00"), false to use basic format (e.g. "-0500")
Returns:
the ISO string representation

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.