org.eigenbase.util14
Class ZonelessTimestamp

java.lang.Object
  extended by org.eigenbase.util14.ZonelessDatetime
      extended by org.eigenbase.util14.ZonelessTimestamp
All Implemented Interfaces:
Serializable, BasicDatetime

public class ZonelessTimestamp
extends ZonelessDatetime

ZonelessTimestamp is a timestamp value without a time zone.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/util14/ZonelessTimestamp.java#9 $
Author:
John Pham
See Also:
Serialized Form

Field Summary
protected  int precision
           
private static long serialVersionUID
          SerialVersionUID created with JDK 1.5 serialver tool.
protected  Timestamp tempTimestamp
           
 
Fields inherited from class org.eigenbase.util14.ZonelessDatetime
internalTime, lastFormat, tempCal, tempFormatter
 
Constructor Summary
ZonelessTimestamp()
          Constructs a ZonelessTimestamp.
ZonelessTimestamp(int precision)
          Constructs a ZonelessTimestamp with precision.
 
Method Summary
protected  Timestamp getTempTimestamp(long value)
          Gets a temporary Timestamp object.
static ZonelessTimestamp parse(String s)
          Parses a string as a ZonelessTimestamp.
static ZonelessTimestamp parse(String s, String format)
          Parses a string as a ZonelessTimestamp using a given format string.
 Object toJdbcObject()
          Returns this datetime as a Jdbc object
 String toString()
          Converts this ZonelessTimestamp to a java.sql.Timestamp and formats it via the toString() method of that class.
 String toString(String format)
          Formats this ZonelessTimestamp via a SimpleDateFormat.
 
Methods inherited from class org.eigenbase.util14.ZonelessDatetime
clearDate, clearTime, getCalendar, getDateValue, getFormatter, getJdbcDate, getJdbcTime, getJdbcTimestamp, getTime, getTimeValue, setZonedTime, setZonelessTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
SerialVersionUID created with JDK 1.5 serialver tool.

See Also:
Constant Field Values

precision

protected final int precision

tempTimestamp

protected transient Timestamp tempTimestamp
Constructor Detail

ZonelessTimestamp

public ZonelessTimestamp()
Constructs a ZonelessTimestamp.


ZonelessTimestamp

public ZonelessTimestamp(int precision)
Constructs a ZonelessTimestamp with precision.

The precision is the number of digits to the right of the decimal point in the seconds value. For example, a TIMESTAMP(3) has a precision to milliseconds.

Parameters:
precision - Number of digits of precision
Method Detail

toJdbcObject

public Object toJdbcObject()
Description copied from class: ZonelessDatetime
Returns this datetime as a Jdbc object

Specified by:
toJdbcObject in class ZonelessDatetime

toString

public String toString()
Converts this ZonelessTimestamp to a java.sql.Timestamp and formats it via the toString() method of that class.

Note: Jdbc formatting always includes a decimal point and at least one digit of milliseconds precision. Trailing zeros, except for the first one after the decimal point, do not appear in the output.

Overrides:
toString in class Object
Returns:
the formatted time string

toString

public String toString(String format)
Formats this ZonelessTimestamp via a SimpleDateFormat. This method does not display milliseconds precision.

Parameters:
format - format string, as required by SimpleDateFormat
Returns:
the formatted timestamp string

parse

public static ZonelessTimestamp parse(String s)
Parses a string as a ZonelessTimestamp.

This method's parsing is strict and may parse fractional seconds (as opposed to just milliseconds.)

Parameters:
s - a string representing a time in ISO format, i.e. according to the SimpleDateFormat string "yyyy-MM-dd HH:mm:ss"
Returns:
the parsed time, or null if parsing failed

parse

public static ZonelessTimestamp parse(String s,
                                      String format)
Parses a string as a ZonelessTimestamp using a given format string.

This method's parsing is strict and may parse fractional seconds (as opposed to just milliseconds.)

Parameters:
s - a string representing a time in ISO format, i.e. according to the SimpleDateFormat string "yyyy-MM-dd HH:mm:ss"
format - format string as per SimpleDateFormat
Returns:
the parsed timestamp, or null if parsing failed

getTempTimestamp

protected Timestamp getTempTimestamp(long value)
Gets a temporary Timestamp object. The same object is returned every time.