org.hsqldb.lib
Class HsqlDateTime
java.lang.Object
|
+--org.hsqldb.lib.HsqlDateTime
- public class HsqlDateTime
- extends java.lang.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
- Author:
- fredt@users
Method Summary |
static java.sql.Date |
dateValue(java.lang.String s)
Converts a string in JDBC date escape format to a Date
value. |
static java.sql.Date |
getDate(java.lang.String dateString,
java.util.Calendar cal)
|
static java.lang.String |
getDateString(java.sql.Date x,
java.util.Calendar cal)
|
static java.sql.Time |
getTime(java.lang.String timeString,
java.util.Calendar cal)
|
static java.sql.Timestamp |
getTimestamp(java.lang.String dateString,
java.util.Calendar cal)
|
static java.lang.String |
getTimestampString(java.sql.Timestamp x,
java.util.Calendar cal)
|
static java.lang.String |
getTimeString(java.sql.Time x,
java.util.Calendar cal)
|
static java.sql.Timestamp |
timestampValue(long time,
int nano)
|
static java.sql.Timestamp |
timestampValue(java.lang.String s)
Converts a string in JDBC timestamp escape format to a
Timestamp value. |
static java.sql.Time |
timeValue(java.lang.String s)
Converts a string in JDBC date escape format to a
Time value. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HsqlDateTime
public HsqlDateTime()
timestampValue
public static java.sql.Timestamp timestampValue(java.lang.String s)
- Converts a string in JDBC timestamp escape format to a
Timestamp
value.
- Parameters:
s
- timestamp in format yyyy-mm-dd hh:mm:ss.fffffffff
where end part can be omitted, or "NOW" (case insensitive)- Returns:
- corresponding
Timestamp
value - Throws:
java.lang.IllegalArgumentException
- if the given argument
does not have the format yyyy-mm-dd hh:mm:ss.fffffffff
timestampValue
public static java.sql.Timestamp timestampValue(long time,
int nano)
- Parameters:
time
- millisecondsnano
- nanoseconds- Returns:
- Timestamp object
dateValue
public static java.sql.Date dateValue(java.lang.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:
java.lang.IllegalArgumentException
- if the given argument
does not have the format yyyy-mm-dd
timeValue
public static java.sql.Time timeValue(java.lang.String s)
- Converts a string in JDBC date escape format to a
Time
value.
- Parameters:
s
- date in format hh:mm:ss
'CURRENT_TIME' or 'NOW' (case independent)- Returns:
- corresponding
Time
value - Throws:
java.lang.IllegalArgumentException
- if the given argument
does not have the format hh:mm:ss
getDate
public static java.sql.Date getDate(java.lang.String dateString,
java.util.Calendar cal)
throws java.sql.SQLException
getTime
public static java.sql.Time getTime(java.lang.String timeString,
java.util.Calendar cal)
throws java.sql.SQLException
getTimestamp
public static java.sql.Timestamp getTimestamp(java.lang.String dateString,
java.util.Calendar cal)
throws java.sql.SQLException
getTimestampString
public static java.lang.String getTimestampString(java.sql.Timestamp x,
java.util.Calendar cal)
throws java.sql.SQLException
getTimeString
public static java.lang.String getTimeString(java.sql.Time x,
java.util.Calendar cal)
throws java.sql.SQLException
getDateString
public static java.lang.String getDateString(java.sql.Date x,
java.util.Calendar cal)
throws java.sql.SQLException
Copyright © 2001 - 2002 HSQL Development Group. All Rights Reserved.