wt.util
Class WrappedTimestamp

java.lang.Object
  extended byjava.util.Date
      extended byjava.sql.Timestamp
          extended bywt.util.WrappedTimestamp
All Implemented Interfaces:
Cloneable, Comparable, Externalizable, Serializable

public class WrappedTimestamp
extends Timestamp
implements Externalizable, Cloneable

This class is a thin wrapper around java.sql.Timestamp that allows the value to remain in string form as long as possible. Only when accessing and manipulating the value will the real java.sql.Timestamp be initialized. This avoids the overhead of constructing internal java.util.Calendar objects and performing timezone conversions unless absolutely necessary.

See Also:
Serialized Form

Field Summary
private static SimpleDateFormat dateFormat
           
private static String formatString
           
private  boolean initialized
           
private  int nanos
           
private static SimpleDateFormat oldDateFormat
           
private static long serialVersionUID
           
private  String time
           
private static String versionID
           
 
Fields inherited from class java.util.Date
 
Constructor Summary
WrappedTimestamp()
          Public constructor required by Externalizable interface - DO NOT USE.
WrappedTimestamp(String time, int nanos)
          Construct a timestamp based on a string representation of the date.
 
Method Summary
 boolean after(Date when)
           
 boolean after(Timestamp ts)
           
 boolean before(Date when)
           
 boolean before(Timestamp ts)
           
 Object clone()
           
 boolean equals(Object obj)
           
 boolean equals(Timestamp ts)
           
 int getDate()
           
 int getDay()
           
 int getHours()
           
 int getMinutes()
           
 int getMonth()
           
 int getNanos()
           
 int getSeconds()
           
 long getTime()
           
 int getTimezoneOffset()
           
 int getYear()
           
 int hashCode()
           
private  void init(boolean for_modify)
           
 void readExternal(ObjectInput s)
           
 void setDate(int date)
           
 void setHours(int hours)
           
 void setMinutes(int minutes)
           
 void setMonth(int month)
           
 void setNanos(int n)
           
 void setSeconds(int seconds)
           
 void setTime(long time)
           
 void setYear(int year)
           
private static Date toDate(String str)
           
 String toGMTString()
           
 String toLocaleString()
           
 String toString()
           
 void writeExternal(ObjectOutput s)
           
 
Methods inherited from class java.sql.Timestamp
compareTo, compareTo, valueOf
 
Methods inherited from class java.util.Date
compareTo, parse, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

formatString

private static final String formatString

dateFormat

private static SimpleDateFormat dateFormat

oldDateFormat

private static SimpleDateFormat oldDateFormat

initialized

private boolean initialized

time

private String time

nanos

private int nanos
Constructor Detail

WrappedTimestamp

public WrappedTimestamp(String time,
                        int nanos)
Construct a timestamp based on a string representation of the date. The string should be in a format parsable by a SimpleDateFormat using format string "dd MM yyyy HH:mm:ss z" such as:
    "12 08 1995 02:30:00 GMT"
 

Parameters:
time - a string representation of this date.
nanos - fractional seconds (0 to 999,999,999 ns)

WrappedTimestamp

public WrappedTimestamp()
Public constructor required by Externalizable interface - DO NOT USE.

Method Detail

toDate

private static Date toDate(String str)
                    throws ParseException
Throws:
ParseException

init

private void init(boolean for_modify)

getNanos

public int getNanos()

setNanos

public void setNanos(int n)

equals

public boolean equals(Timestamp ts)

before

public boolean before(Timestamp ts)

after

public boolean after(Timestamp ts)

getYear

public int getYear()

setYear

public void setYear(int year)

getMonth

public int getMonth()

setMonth

public void setMonth(int month)

getDate

public int getDate()

setDate

public void setDate(int date)

getDay

public int getDay()

getHours

public int getHours()

setHours

public void setHours(int hours)

getMinutes

public int getMinutes()

setMinutes

public void setMinutes(int minutes)

getSeconds

public int getSeconds()

setSeconds

public void setSeconds(int seconds)

getTime

public long getTime()

setTime

public void setTime(long time)

before

public boolean before(Date when)

after

public boolean after(Date when)

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()

toLocaleString

public String toLocaleString()

toGMTString

public String toGMTString()

getTimezoneOffset

public int getTimezoneOffset()

clone

public Object clone()

writeExternal

public void writeExternal(ObjectOutput s)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput s)
                  throws IOException
Specified by:
readExternal in interface Externalizable
Throws:
IOException