org.eigenbase.util14
Class ZonelessTime

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

public class ZonelessTime
extends ZonelessDatetime

ZonelessTime is a time value without a time zone.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/util14/ZonelessTime.java#7 $
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  Time tempTime
           
 
Fields inherited from class org.eigenbase.util14.ZonelessDatetime
internalTime, lastFormat, tempCal, tempFormatter
 
Constructor Summary
ZonelessTime()
          Constructs a ZonelessTime
ZonelessTime(int precision)
          Constructs a ZonelessTime with precision.
 
Method Summary
 long getJdbcTimestamp(TimeZone zone)
          Override ZonelessDatetime.
protected  Time getTempTime(long value)
          Gets a temporary Time object.
static ZonelessTime parse(String s)
          Parses a string as a ZonelessTime.
static ZonelessTime parse(String s, String format)
          Parses a string as a ZonelessTime using a given format string.
 void setZonedTime(long value, TimeZone zone)
          Sets this datetime via a zoned time value.
 void setZonelessTime(long value)
          Sets this datetime via a zoneless time value.
 Object toJdbcObject()
          Returns this datetime as a Jdbc object
 String toString()
          Converts this ZonelessTime to a java.sql.Time and formats it via the toString() method of that class.
 String toString(String format)
          Formats this ZonelessTime via a SimpleDateFormat
 
Methods inherited from class org.eigenbase.util14.ZonelessDatetime
clearDate, clearTime, getCalendar, getDateValue, getFormatter, getJdbcDate, getJdbcTime, getTime, getTimeValue
 
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

tempTime

protected transient Time tempTime
Constructor Detail

ZonelessTime

public ZonelessTime()
Constructs a ZonelessTime


ZonelessTime

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

The precision is the number of digits to the right of the decimal point in the seconds value. For example, a TIME(6) has a precision to microseconds.

Parameters:
precision - Number of digits of precision
Method Detail

setZonelessTime

public void setZonelessTime(long value)
Description copied from interface: BasicDatetime
Sets this datetime via a zoneless time value. See class comments for more information.

Specified by:
setZonelessTime in interface BasicDatetime
Overrides:
setZonelessTime in class ZonelessDatetime

setZonedTime

public void setZonedTime(long value,
                         TimeZone zone)
Description copied from interface: BasicDatetime
Sets this datetime via a zoned time value. See class comments for more information.

Specified by:
setZonedTime in interface BasicDatetime
Overrides:
setZonedTime in class ZonelessDatetime

toJdbcObject

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

Specified by:
toJdbcObject in class ZonelessDatetime

getJdbcTimestamp

public long getJdbcTimestamp(TimeZone zone)
Override ZonelessDatetime.

NOTE: the returned timestamp is based on the current date of the specified time zone, rather than the context variable for current_date, as specified by the SQL standard.

Overrides:
getJdbcTimestamp in class ZonelessDatetime
Parameters:
zone - time zone in which to generate a time value for

toString

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

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

toString

public String toString(String format)
Formats this ZonelessTime via a SimpleDateFormat

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

parse

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

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

parse

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

Parameters:
s - a string representing a time the given format
format - format string as per SimpleDateFormat
Returns:
the parsed time, or null if parsing failed

getTempTime

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