com.ibm.util
Class SimpleTimeZoneAdapter

java.lang.Object
  |
  +--java.util.TimeZone
        |
        +--com.ibm.util.SimpleTimeZoneAdapter
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class SimpleTimeZoneAdapter
extends java.util.TimeZone

SimpleTimeZoneAdapter wraps a com.ibm.util.SimpleTimeZone and inherits from java.util.TimeZone. Without this class, we would need to 'port' java.util.Date to com.ibm.util as well, so that Date could interoperate properly with the com.ibm.util TimeZone and Calendar classes. With this class, we can (mostly) use java.util.Date together with com.ibm.util classes.

This solution is imperfect because of the faulty design of java.util.TimeZone. Specifically, TZ contains a package private method, getOffset(), that should really be public. Because it is package private, it cannot be overridden from where we are, and we cannot properly delegate its operation to our contained com.ibm.util.STZ object.

For the moment we live with this problem. It appear not to cause too much trouble since most real computations happen using the com.ibm.util classes. However, if this becomes a problem in the future, we will have to stop using this adapter, and 'port' java.util.Date into com.ibm.util.

Author:
Alan Liu
See Also:
TimeZone.setDefault(com.ibm.util.TimeZone), Serialized Form

Fields inherited from class java.util.TimeZone
LONG, SHORT
 
Constructor Summary
SimpleTimeZoneAdapter(SimpleTimeZone zone)
           
 
Method Summary
 java.lang.Object clone()
          Overrides Cloneable
 boolean equals(java.lang.Object obj)
          Compares the equality of two SimpleTimeZone objects.
 java.lang.String getID()
          Override TimeZone
 int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
          Override TimeZone
 int getRawOffset()
          Overrides TimeZone Gets the GMT offset for this time zone.
 int hashCode()
          Override hashCode.
 boolean hasSameRules(java.util.TimeZone other)
          Override TimeZone
 boolean inDaylightTime(java.util.Date date)
          Overrides TimeZone
 void setID(java.lang.String ID)
          Override TimeZone
 void setRawOffset(int offsetMillis)
          Overrides TimeZone
 java.lang.String toString()
          Return a string representation of this time zone.
 boolean useDaylightTime()
          Overrides TimeZone
 
Methods inherited from class java.util.TimeZone
getAvailableIDs, getAvailableIDs, getDefault, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getTimeZone, setDefault
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTimeZoneAdapter

public SimpleTimeZoneAdapter(SimpleTimeZone zone)
Method Detail

getID

public java.lang.String getID()
Override TimeZone
Overrides:
getID in class java.util.TimeZone

setID

public void setID(java.lang.String ID)
Override TimeZone
Overrides:
setID in class java.util.TimeZone

hasSameRules

public boolean hasSameRules(java.util.TimeZone other)
Override TimeZone
Overrides:
hasSameRules in class java.util.TimeZone

getOffset

public int getOffset(int era,
                     int year,
                     int month,
                     int day,
                     int dayOfWeek,
                     int millis)
Override TimeZone
Overrides:
getOffset in class java.util.TimeZone

getRawOffset

public int getRawOffset()
Overrides TimeZone Gets the GMT offset for this time zone.
Overrides:
getRawOffset in class java.util.TimeZone

setRawOffset

public void setRawOffset(int offsetMillis)
Overrides TimeZone
Overrides:
setRawOffset in class java.util.TimeZone

useDaylightTime

public boolean useDaylightTime()
Overrides TimeZone
Overrides:
useDaylightTime in class java.util.TimeZone

inDaylightTime

public boolean inDaylightTime(java.util.Date date)
Overrides TimeZone
Overrides:
inDaylightTime in class java.util.TimeZone

clone

public java.lang.Object clone()
Overrides Cloneable
Overrides:
clone in class java.util.TimeZone

hashCode

public int hashCode()
Override hashCode.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compares the equality of two SimpleTimeZone objects.
Overrides:
equals in class java.lang.Object
Parameters:
obj - The SimpleTimeZone object to be compared with.
Returns:
True if the given obj is the same as this SimpleTimeZone object; false otherwise.

toString

public java.lang.String toString()
Return a string representation of this time zone.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this time zone.


Copyright (c) 2001 IBM Corporation and others.