org.axiondb.util

Class DateTimeUtils

public final class DateTimeUtils extends Object

Methods to support manipulation and conversion of date, time and timestamp values.

Version: $Revision: 1.11 $ $Date: 2005/12/20 18:32:42 $

Author: Jonathan Giron Ahimanikya Satapathy

Field Summary
static intDAY
Constant representing day interval
static intHOUR
Constant representing hour time interval
static intMILLISECOND
Constant representing millisecond time interval
static intMINUTE
Constant representing minute time interval
static intMONTH
Constant representing month interval
static intQUARTER
Constant representing quarter interval
static intSECOND
Constant representing second time interval
static intWEEK
Constant representing week interval
static intYEAR
Constant representing year interval
Method Summary
static StringconvertToChar(Timestamp timestamp, String formatStr)
Creates a String representation of the given Timestamp object, using the given format string as a template and the current Axion time zone.
static StringconvertToChar(Timestamp timestamp, String formatStr, TimeZone timezone)
Creates a String representation of the given Timestamp object, using the given format string as a template, the given time zone, and the current default Locale.
static StringconvertToChar(Timestamp timestamp, String formatStr, TimeZone timezone, Locale locale)
Creates a String representation of the given Timestamp object, using the given format string as a template, the given time zone, and the given Locale.
static TimestampconvertToTimestamp(String dateStr, String formatStr)
Creates a String representation of the given Timestamp object, using the given format string as a template and the current Axion time zone.
static TimestampconvertToTimestamp(String dateStr, String formatStr, TimeZone timezone)
Creates a String representation of the given Timestamp object, using the given format string as a template and the given time zone.
static TimestampconvertToTimestamp(String dateStr, String formatStr, TimeZone timezone, Locale locale)
Creates a String representation of the given Timestamp object, using the given format string as a template, the given time zone, and the given Locale
static StringgetDatePart(Timestamp t, String partIdent)
Extracts the specified date/time element from the given Timestamp, using the default Locale.
static StringgetDatePart(Timestamp t, String partIdent, Locale locale)
Extracts the specified date/time element from the given Timestamp, using the given Locale.
static StringgetPartMnemonicFor(String partString)
static intlabelToCode(String value)
Converts the given value, which represents a date or time interval, to its corresponding constant value.

Field Detail

DAY

public static final int DAY
Constant representing day interval

HOUR

public static final int HOUR
Constant representing hour time interval

MILLISECOND

public static final int MILLISECOND
Constant representing millisecond time interval

MINUTE

public static final int MINUTE
Constant representing minute time interval

MONTH

public static final int MONTH
Constant representing month interval

QUARTER

public static final int QUARTER
Constant representing quarter interval

SECOND

public static final int SECOND
Constant representing second time interval

WEEK

public static final int WEEK
Constant representing week interval

YEAR

public static final int YEAR
Constant representing year interval

Method Detail

convertToChar

public static String convertToChar(Timestamp timestamp, String formatStr)
Creates a String representation of the given Timestamp object, using the given format string as a template and the current Axion time zone.

Parameters: timestamp Timestamp object to be converted to a String representation formatStr template describing the desired format for the String representation of timestamp

Returns: formatted String representation of timestamp

Throws: AxionException if format is invalid

See Also: DateTimeUtils

convertToChar

public static String convertToChar(Timestamp timestamp, String formatStr, TimeZone timezone)
Creates a String representation of the given Timestamp object, using the given format string as a template, the given time zone, and the current default Locale.

Parameters: timestamp Timestamp object to be converted to a String representation formatStr template describing the desired format for the String representation of timestamp timezone TimeZone to use in interpreting the value of timestamp to the desired String representation

Returns: formatted String representation of timestamp

Throws: AxionException if format is invalid

See Also: DateTimeUtils DateTimeUtils

convertToChar

public static String convertToChar(Timestamp timestamp, String formatStr, TimeZone timezone, Locale locale)
Creates a String representation of the given Timestamp object, using the given format string as a template, the given time zone, and the given Locale.

Parameters: timestamp Timestamp object to be converted to a String representation formatStr template describing the desired format for the String representation of timestamp timezone TimeZone to use in interpreting the value of timestamp to the desired String representation locale Locale to use in resolving date components

Returns: formatted String representation of timestamp

Throws: AxionException if format is invalid

See Also: DateTimeUtils DateTimeUtils

convertToTimestamp

public static Timestamp convertToTimestamp(String dateStr, String formatStr)
Creates a String representation of the given Timestamp object, using the given format string as a template and the current Axion time zone.

Parameters: dateStr String representation of Timestamp to be returned formatStr template describing the format of dateStr

Returns: Timestamp containing date represented by dateStr

Throws: AxionException if format is invalid

See Also: DateTimeUtils DateTimeUtils

convertToTimestamp

public static Timestamp convertToTimestamp(String dateStr, String formatStr, TimeZone timezone)
Creates a String representation of the given Timestamp object, using the given format string as a template and the given time zone.

Parameters: dateStr String representation of Timestamp to be returned formatStr template describing the format of dateStr timezone TimeZone to use in interpreting the value of dateStr

Returns: Timestamp containing date represented by dateStr

Throws: AxionException if format is invalid

See Also: DateTimeUtils

convertToTimestamp

public static Timestamp convertToTimestamp(String dateStr, String formatStr, TimeZone timezone, Locale locale)
Creates a String representation of the given Timestamp object, using the given format string as a template, the given time zone, and the given Locale

Parameters: dateStr String representation of Timestamp to be returned formatStr template describing the format of dateStr timezone TimeZone to use in interpreting the value of dateStr locale Locale to use in resolving date components

Returns: Timestamp containing date represented by dateStr

Throws: AxionException if format is invalid

See Also: DateTimeUtils DateTimeUtils

getDatePart

public static String getDatePart(Timestamp t, String partIdent)
Extracts the specified date/time element from the given Timestamp, using the default Locale.

Parameters: t timestamp from which date/time element will be extracted partIdent date part to extract, e.g., 'yyyy', 'mm', etc.

Returns: String representation of extracted date/time element

Throws: AxionException if error occurs during extraction

See Also: DateTimeUtils

getDatePart

public static String getDatePart(Timestamp t, String partIdent, Locale locale)
Extracts the specified date/time element from the given Timestamp, using the given Locale.

Parameters: t timestamp from which date/time element will be extracted partIdent date part to extract, e.g., 'yyyy', 'mm', etc. locale Locale to use in resolving date components

Returns: String representation of extracted date/time element

Throws: AxionException if error occurs during extraction

See Also: DateTimeUtils

getPartMnemonicFor

public static String getPartMnemonicFor(String partString)

Parameters: partCode

Returns:

labelToCode

public static int labelToCode(String value)
Converts the given value, which represents a date or time interval, to its corresponding constant value.

Parameters: value String representation of date or time interval

Returns: constant value corresponding to value

Throws: AxionException if value does not have a corresponding constant.