org.hsqldb
Class HsqlDateTime

java.lang.Object
  extended byorg.hsqldb.HsqlDateTime

public class HsqlDateTime
extends Object

collection of static methods to convert Date, Time and Timestamp strings into corresponding Java objects. Also accepts SQL literals such as NOW, TODAY as valid strings and returns the current date / time / datetime. Compatible with jdk 1.1.x.

Was reviewed for 1.7.2 resulting in centralising all DATETIME related operstions.

HSQLDB uses the client and server's default timezone for all DATETIME operations. It stores the DATETIME values in .log and .script files using the default local of the server. The same values are stored as binary UTC timestamps in .data files. If the database is trasported from one timezone to another, then the DATETIME values in cached tables will be handled as UTC but those in other tables will be treated as local. So a timestamp representing 12 noon stored in Tokyo timezone will be treated as 9 pm in London when stored in a cached table but the same value stored in a memory table will be treated as 12 noon.

Since:
1.7.0
Version:
1.7.2
Author:
fredt@users

Constructor Summary
HsqlDateTime()
           
 
Method Summary
static Date dateValue(String s)
          Converts a string in JDBC date escape format to a Date value.
static Time getCurrentTime()
           
static String getDateString(Date x, Calendar cal)
           
static Date getNormalisedDate(Date d)
           
static long getNormalisedDate(long d)
           
static Date getNormalisedDate(Timestamp ts)
           
static Time getNormalisedTime(long t)
           
static Time getNormalisedTime(Time t)
           
static Time getNormalisedTime(Timestamp ts)
           
static Timestamp getNormalisedTimestamp(Date d)
           
static Timestamp getNormalisedTimestamp(Time t)
           
static String getTimestampString(Timestamp x, Calendar cal)
           
static String getTimeString(Time x, Calendar cal)
           
static void resetToDate(Calendar cal)
           
static void resetToTime(Calendar cal)
           
static Timestamp timestampValue(long time, int nano)
           
static Time timeValue(String s)
          Converts a string in JDBC date escape format to a Time value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HsqlDateTime

public HsqlDateTime()
Method Detail

timestampValue

public static Timestamp timestampValue(long time,
                                       int nano)
Parameters:
time - milliseconds
nano - nanoseconds
Returns:
Timestamp object

dateValue

public static Date dateValue(String s)
Converts a string in JDBC date escape format to a Date value. Also accepts Timestamp values.

Parameters:
s - date in format yyyy-mm-dd, 'TODAY', 'NOW', 'CURRENT_DATE', 'SYSDATE' (case independent)
Returns:
corresponding Date value
Throws:
IllegalArgumentException - if the given argument does not have the format yyyy-mm-dd

timeValue

public static Time timeValue(String s)
Converts a string in JDBC date escape format to a Time value.

Parameters:
s - date in format hh:mm:ss 'CURRENT_TIME' (case independent)
Returns:
corresponding Time value
Throws:
IllegalArgumentException - if the given argument does not have the format hh:mm:ss

getCurrentTime

public static Time getCurrentTime()

getTimestampString

public static String getTimestampString(Timestamp x,
                                        Calendar cal)
                                 throws Exception
Throws:
Exception

getTimeString

public static String getTimeString(Time x,
                                   Calendar cal)
                            throws Exception
Throws:
Exception

getDateString

public static String getDateString(Date x,
                                   Calendar cal)
                            throws Exception
Throws:
Exception

resetToDate

public static void resetToDate(Calendar cal)

resetToTime

public static void resetToTime(Calendar cal)

getNormalisedTime

public static Time getNormalisedTime(long t)

getNormalisedTime

public static Time getNormalisedTime(Time t)

getNormalisedTime

public static Time getNormalisedTime(Timestamp ts)

getNormalisedDate

public static long getNormalisedDate(long d)

getNormalisedDate

public static Date getNormalisedDate(Timestamp ts)

getNormalisedDate

public static Date getNormalisedDate(Date d)

getNormalisedTimestamp

public static Timestamp getNormalisedTimestamp(Time t)

getNormalisedTimestamp

public static Timestamp getNormalisedTimestamp(Date d)


Copyright © 2001 - 2004 HSQL Development Group. All Rights Reserved.