|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.osesb.utilities.language.DateTimeConversionUtility
public final class DateTimeConversionUtility
Centralized date-time processing for framework components.
DateTimeConversionUtility provides methods for converting among Strings, java.util.Date, java.util.Calendar, java.sql.Date, java.sql.Time, and java.sql.Timestamp. DateTimeConversionUtility can be used as an instance object or as a static class:
| Field Summary | |
|---|---|
protected java.text.SimpleDateFormat |
dateFormatter
SimpleDateFormat for Dates. |
protected java.util.Properties |
datetimeProperties
Date-time Properties that override defaults formats for Date, Time, and Timestamp. |
protected java.lang.String |
datetimePropertiesFile
The loaded Properties file, if any. |
static java.lang.String |
DEFAULT_DATE_FORMAT
Default Date format. |
static java.lang.String |
DEFAULT_DATETIME_PROPERTIES_FILE
The default name for the dateTime format properties file. |
static java.lang.String |
DEFAULT_TIME_FORMAT
Default Time format. |
static java.lang.String |
DEFAULT_TIMESTAMP_FORMAT
Default Timestamp format. |
static java.lang.String |
SYSTEM_DATETIME_PROPERTIES_FILE
The system property key used to identify the dateTime format properties file. |
protected static java.lang.String |
thisClassName
The full name of this class. |
protected java.text.SimpleDateFormat |
timeFormatter
SimpleDateFormat for Time. |
protected java.text.SimpleDateFormat |
timestampFormatter
SimpleDateFormat for Timestamps. |
| Constructor Summary | |
|---|---|
DateTimeConversionUtility()
Creates a new instance of DateTimeConversionUtility. |
|
| Method Summary | |
|---|---|
static java.util.Date |
convertCalendarToDate(java.util.Calendar calendar)
Converts an instance of java.util.Calendar into and instance of java.util.Date. |
java.lang.String |
convertCalendarToString(java.util.Calendar calendar)
Converts an instance of java.util.Calendar into a String |
static java.util.Calendar |
convertDateToCalendar(java.util.Date date)
Converts an instance of java.util.Date into an instance of java.util.Calendar. |
java.lang.String |
convertDateToString(java.util.Date date)
Converts an instance of java.util.Date into a String |
static java.lang.String |
convertDateToString(java.util.Date date,
java.lang.String dateTimeFormat)
Converts an instance of java.util.Date into a String |
java.lang.String |
convertSQLDateToString(java.sql.Date columnValue)
Converts an java.sql.Date to a String based on the configured format or the default format. |
static java.lang.String |
convertSQLDateToString(java.sql.Date columnValue,
java.lang.String dateTimeFormat)
Converts an java.sql.Date to a String. |
java.lang.String |
convertSQLTimestampToString(java.sql.Timestamp columnValue)
Converts an java.sql.Timestamp to a String based on the configured format or the default format. |
static java.lang.String |
convertSQLTimestampToString(java.sql.Timestamp columnValue,
java.lang.String dateTimeFormat)
Converts an java.sql.Timestamp to a String. |
java.lang.String |
convertSQLTimeToString(java.sql.Time columnValue)
Converts an java.sql.Time to a String based on the configured format or the default format. |
static java.lang.String |
convertSQLTimeToString(java.sql.Time columnValue,
java.lang.String dateTimeFormat)
Converts an java.sql.Time to a String. |
java.util.Calendar |
convertStringToCalendar(java.lang.String dateTime)
Converts a datetime string into and instance of java.util.Calendar |
java.util.Date |
convertStringToDate(java.lang.String dateTime)
Converts a datetime string into and instance of java.util.Date |
static java.util.Date |
convertStringToDate(java.lang.String dateTime,
java.lang.String dateTimeFormat)
Converts a datetime string into and instance of java.util.Date using the specified format. |
java.lang.String |
getDateFormat()
Return the format for converting between dates and Strings. |
java.lang.String |
getTimeFormat()
Return the format for converting between times and Strings. |
java.lang.String |
getTimestampFormat()
Return the format for converting between timestamps and Strings. |
protected void |
loadDatetimeProperties()
Loads datetimeProperties from a properties file using the following plan: 1. |
static void |
main(java.lang.String[] args)
main(): For testing and sandboxing. |
void |
setDateFormat(java.lang.String dateFormat)
Set the format for converting between dates and Strings. |
void |
setTimeFormat(java.lang.String timeFormat)
Set the format for converting between times and Strings. |
void |
setTimestampFormat(java.lang.String timestampFormat)
Set the format for converting between timestamps and Strings. |
java.lang.String |
toString()
Returns the String representation of the DateTimeConversionUtility. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static java.lang.String thisClassName
protected java.util.Properties datetimeProperties
protected java.lang.String datetimePropertiesFile
public static final java.lang.String DEFAULT_DATETIME_PROPERTIES_FILE
public static final java.lang.String SYSTEM_DATETIME_PROPERTIES_FILE
public static final java.lang.String DEFAULT_DATE_FORMAT
protected java.text.SimpleDateFormat dateFormatter
public static final java.lang.String DEFAULT_TIME_FORMAT
protected java.text.SimpleDateFormat timeFormatter
public static final java.lang.String DEFAULT_TIMESTAMP_FORMAT
protected java.text.SimpleDateFormat timestampFormatter
| Constructor Detail |
|---|
public DateTimeConversionUtility()
| Method Detail |
|---|
protected final void loadDatetimeProperties()
public java.lang.String convertSQLDateToString(java.sql.Date columnValue)
throws java.lang.Exception
columnValue - The java.sql.Date to convert.
java.lang.Exception - if an error is encountered during the conversion.
public static java.lang.String convertSQLDateToString(java.sql.Date columnValue,
java.lang.String dateTimeFormat)
throws java.lang.Exception
columnValue - The java.sql.Date to convert.dateTimeFormat - The dateTime format to use for the conversion.
java.lang.Exception - if an error is encountered during the conversion.
public java.lang.String convertSQLTimeToString(java.sql.Time columnValue)
throws java.lang.Exception
columnValue - The java.sql.Time to convert.
java.lang.Exception - if an error is encountered during the conversion.
public static java.lang.String convertSQLTimeToString(java.sql.Time columnValue,
java.lang.String dateTimeFormat)
throws java.lang.Exception
columnValue - The java.sql.Timestamp to convert.dateTimeFormat - The dateTime format to use for the conversion.
java.lang.Exception - if an error is encountered during the conversion.
public java.lang.String convertSQLTimestampToString(java.sql.Timestamp columnValue)
throws java.lang.Exception
columnValue - The java.sql.Timestamp to convert.
java.lang.Exception - if an error is encountered during the conversion.
public static java.lang.String convertSQLTimestampToString(java.sql.Timestamp columnValue,
java.lang.String dateTimeFormat)
throws java.lang.Exception
columnValue - The java.sql.Timestamp to convert.dateTimeFormat - The dateTime format to use for the conversion.
java.lang.Exception - if an error is encountered during the conversion.
public java.util.Calendar convertStringToCalendar(java.lang.String dateTime)
throws java.lang.Exception
dateTime - A datetime string.
java.lang.Exception - if an error is encountered during the conversion.
public java.lang.String convertCalendarToString(java.util.Calendar calendar)
throws java.lang.Exception
calendar - An instance of java.util.Calendar.
java.lang.Exception - if an error is encountered during the conversion.
public java.util.Date convertStringToDate(java.lang.String dateTime)
throws java.lang.Exception
dateTime - A datetime string
java.lang.Exception - if an error is encountered during the conversion.
public static java.util.Date convertStringToDate(java.lang.String dateTime,
java.lang.String dateTimeFormat)
throws java.lang.Exception
dateTime - A datetime string to convert.dateTimeFormat - The dateTime format to use for the conversion.
java.lang.Exception - if an error is encountered during the conversion.
public java.lang.String convertDateToString(java.util.Date date)
throws java.lang.Exception
date - an Instance of java.util.Date.
java.lang.Exception - if an error is encountered during the conversion.
public static java.lang.String convertDateToString(java.util.Date date,
java.lang.String dateTimeFormat)
throws java.lang.Exception
date - an Instance of java.util.Date.dateTimeFormat - The dateTime format to use for the conversion.
java.lang.Exception - if an error is encountered during the conversion.
public static java.util.Date convertCalendarToDate(java.util.Calendar calendar)
throws java.lang.Exception
calendar - Instance of java.util.Calendar.
java.lang.Exception - if an error is encountered during the conversion.
public static java.util.Calendar convertDateToCalendar(java.util.Date date)
throws java.lang.Exception
date - Instance of java.util.Date.
java.lang.Exception - if an error is encountered during the conversion.public java.lang.String getDateFormat()
public void setDateFormat(java.lang.String dateFormat)
throws java.lang.Exception
dateFormat - A valid Date format String.
java.lang.Exception - if invoked with an invalid dateFormat.public java.lang.String getTimeFormat()
public void setTimeFormat(java.lang.String timeFormat)
throws java.lang.Exception
timeFormat - A valid Time format String.
java.lang.Exception - if invoked with an invalid timeFormat.public java.lang.String getTimestampFormat()
public void setTimestampFormat(java.lang.String timestampFormat)
throws java.lang.Exception
timestampFormat - A valid Timestamp format String
java.lang.Exception - if invoked with an invalid timestampFormat.public java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] args)
args - commandline arguments
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||