org.axiondb.util
Class DateTimeUtils

java.lang.Object
  extended by org.axiondb.util.DateTimeUtils

public final class DateTimeUtils
extends Object

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

Version:
$Revision: 1.4 $ $Date: 2004/09/04 01:22:00 $

Field Summary
static int DAY
          Constant representing day interval
static int HOUR
          Constant representing hour time interval
static int MILLISECOND
          Constant representing millisecond time interval
static int MINUTE
          Constant representing minute time interval
static int MONTH
          Constant representing month interval
static int QUARTER
          Constant representing quarter interval
static int SECOND
          Constant representing second time interval
static int WEEK
          Constant representing week interval
static int YEAR
          Constant representing year interval
 
Constructor Summary
DateTimeUtils()
           
 
Method Summary
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 timezone.
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 timezone, and the current default Locale.
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 timezone, and the given Locale.
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 timezone.
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 timezone.
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 timezone, and the given Locale
static String getDatePart(Timestamp t, String partIdent)
          Extracts the specified date/time element from the given Timestamp, using the default Locale.
static String getDatePart(Timestamp t, String partIdent, Locale locale)
          Extracts the specified date/time element from the given Timestamp, using the given Locale.
static String getPartMnemonicFor(String partString)
           
static int labelToCode(String value)
          Converts the given value, which represents a date or time interval, to its corresponding constant value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLISECOND

public static final int MILLISECOND
Constant representing millisecond time interval

See Also:
Constant Field Values

SECOND

public static final int SECOND
Constant representing second time interval

See Also:
Constant Field Values

MINUTE

public static final int MINUTE
Constant representing minute time interval

See Also:
Constant Field Values

HOUR

public static final int HOUR
Constant representing hour time interval

See Also:
Constant Field Values

DAY

public static final int DAY
Constant representing day interval

See Also:
Constant Field Values

WEEK

public static final int WEEK
Constant representing week interval

See Also:
Constant Field Values

MONTH

public static final int MONTH
Constant representing month interval

See Also:
Constant Field Values

QUARTER

public static final int QUARTER
Constant representing quarter interval

See Also:
Constant Field Values

YEAR

public static final int YEAR
Constant representing year interval

See Also:
Constant Field Values
Constructor Detail

DateTimeUtils

public DateTimeUtils()
Method Detail

convertToChar

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

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:
convertToChar(Timestamp, String, java.util.TimeZone)

convertToChar

public static String convertToChar(Timestamp timestamp,
                                   String formatStr,
                                   TimeZone timezone)
                            throws AxionException
Creates a String representation of the given Timestamp object, using the given format string as a template, the given timezone, 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:
convertToChar(Timestamp, String), convertToChar(Timestamp, String, TimeZone, Locale)

convertToChar

public static String convertToChar(Timestamp timestamp,
                                   String formatStr,
                                   TimeZone timezone,
                                   Locale locale)
                            throws AxionException
Creates a String representation of the given Timestamp object, using the given format string as a template, the given timezone, 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:
convertToChar(Timestamp, String), convertToChar(Timestamp, String, TimeZone)

convertToTimestamp

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

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:
convertToTimestamp(String, String, java.util.TimeZone), convertToTimestamp(String, String, java.util.TimeZone, java.util.Locale)

convertToTimestamp

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

Parameters:
dateStr - String representation of Timestamp to be returned
formatStr - template describing the format of dateStr
timezone - TimeZone to use in interpreseting the value of dateStr
Returns:
Timestamp containing date represented by dateStr
Throws:
AxionException - if format is invalid
See Also:
convertToTimestamp(String, String), convertToTimestamp(String, String, java.util.TimeZone, java.util.Locale)

convertToTimestamp

public static Timestamp convertToTimestamp(String dateStr,
                                           String formatStr,
                                           TimeZone timezone,
                                           Locale locale)
                                    throws AxionException
Creates a String representation of the given Timestamp object, using the given format string as a template, the given timezone, 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 interpreseting 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:
convertToTimestamp(String, String), convertToTimestamp(String, String, java.util.TimeZone)

getDatePart

public static String getDatePart(Timestamp t,
                                 String partIdent)
                          throws AxionException
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:
getDatePart(Timestamp, String, Locale)

getDatePart

public static String getDatePart(Timestamp t,
                                 String partIdent,
                                 Locale locale)
                          throws AxionException
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:
getDatePart(Timestamp, String)

labelToCode

public static int labelToCode(String value)
                       throws AxionException
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.

getPartMnemonicFor

public static String getPartMnemonicFor(String partString)
                                 throws AxionException
Parameters:
partCode -
Returns:
Throws:
AxionException