Rakesh API

biz.wedoit4u.ejb.session
Class DateFormatterBean

java.lang.Object
  extended by biz.wedoit4u.ejb.session.SessionBeanAdapter
      extended by biz.wedoit4u.ejb.session.DateFormatterBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class DateFormatterBean
extends SessionBeanAdapter

Common date transformations that are performed.

Version:
$Id: DateFormatterBean.java,v 1.3 2004/05/26 11:42:36 rakesh Exp $
Author:
Rakesh Vidyadharan 17th September 2003

Copyright 2003, wedoit4u.biz

See Also:
Serialized Form

Field Summary
private  java.text.SimpleDateFormat dateTimeFormat
          The formatter that will be used for ISO 8601 date-time formats.
static java.lang.String DATETIMEFORMAT
          The format that will be used to specify date-time values in the ISO 8601 format.
private  java.text.SimpleDateFormat dayFormat
          The formatter that will be used for ISO 8601 day formats.
static java.lang.String DAYFORMAT
          The format that will be used to specify day values to encode/decode date objects.
private  java.text.SimpleDateFormat dayFormatWithTimeZone
          The formatter that will be used for ISO 8601 day formats.
private  java.text.SimpleDateFormat sqlTimestampFormat
          The formatter that will be used for SQL Timestamp formats.
static java.lang.String SQLTIMESTAMPFORMAT
          The format that will be used to specify date-time values to encode/decode date objects in SQL timestamp format.
private  java.text.SimpleDateFormat timeFormat
          The formatter that will be used for ISO 8601 time formats.
static java.lang.String TIMEFORMAT
          The format that will be used to specify time values to encode/decode date objects.
 
Fields inherited from class biz.wedoit4u.ejb.session.SessionBeanAdapter
sessionContext
 
Constructor Summary
DateFormatterBean()
          Default constructor.
 
Method Summary
 java.lang.String getDateTime(java.util.Date date)
          Formats the specified Date object in ISO 8601 date-time format (yyyy-MM-dd'T'HH-mm-ss'Z').
 java.util.Date getDateTime(java.lang.String date)
          Parses the specified String object in ISO 8601 date-time format (yyyy-MM-dd'T'HH-mm-ss'Z') into a Java Date.
 java.lang.String getDay(java.util.Date date)
          Formats the specified Date object in ISO 8601 day format (yyyy-MM-dd).
 java.util.Date getDay(java.lang.String date)
          Parses the specified String in ISO 8601 day format (yyyy-MM-dd) into a Java Date.
 java.lang.String getSQLTimestamp(java.util.Date date)
          Formats the specified Date object in SQL timestamp format (yyyy-MM-dd HH-mm-ss).
 java.util.Date getSQLTimestamp(java.lang.String date)
          Parses the specified String object in SQL timestamp format (yyyy-MM-dd HH-mm-ss) into a Java Date.
 java.lang.String getTime(java.util.Date date)
          Formats the specified Date object in ISO 8601 time format (HH:mm:ss).
 java.util.Date getTime(java.lang.String date)
          Parses the specified String object in ISO 8601 time format (HH:mm:ss) into a Java Date.
 
Methods inherited from class biz.wedoit4u.ejb.session.SessionBeanAdapter
ejbActivate, ejbCreate, ejbPassivate, ejbRemove, setSessionContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DAYFORMAT

public static final java.lang.String DAYFORMAT
The format that will be used to specify day values to encode/decode date objects.

See Also:
Constant Field Values

TIMEFORMAT

public static final java.lang.String TIMEFORMAT
The format that will be used to specify time values to encode/decode date objects.

See Also:
Constant Field Values

SQLTIMESTAMPFORMAT

public static final java.lang.String SQLTIMESTAMPFORMAT
The format that will be used to specify date-time values to encode/decode date objects in SQL timestamp format.

See Also:
Constant Field Values

DATETIMEFORMAT

public static final java.lang.String DATETIMEFORMAT
The format that will be used to specify date-time values in the ISO 8601 format.

See Also:
Constant Field Values

dayFormat

private java.text.SimpleDateFormat dayFormat
The formatter that will be used for ISO 8601 day formats. No time-zone is set for this formatter.

See Also:
DAYFORMAT

dayFormatWithTimeZone

private java.text.SimpleDateFormat dayFormatWithTimeZone
The formatter that will be used for ISO 8601 day formats.

See Also:
DAYFORMAT

timeFormat

private java.text.SimpleDateFormat timeFormat
The formatter that will be used for ISO 8601 time formats. No time-zone is set for this formatter.

See Also:
TIMEFORMAT

dateTimeFormat

private java.text.SimpleDateFormat dateTimeFormat
The formatter that will be used for ISO 8601 date-time formats. No time-zone is set for this formatter.

See Also:
DATETIMEFORMAT

sqlTimestampFormat

private java.text.SimpleDateFormat sqlTimestampFormat
The formatter that will be used for SQL Timestamp formats. No time-zone is set for this formatter.

See Also:
SQLTIMESTAMPFORMAT
Constructor Detail

DateFormatterBean

public DateFormatterBean()
Default constructor. No special code required.

Method Detail

getDay

public java.lang.String getDay(java.util.Date date)
Formats the specified Date object in ISO 8601 day format (yyyy-MM-dd). This is also the SQL Date format.

Parameters:
date - - The input date that is to be formatted.
Returns:
String - The parsed date value.

getDay

public java.util.Date getDay(java.lang.String date)
                      throws java.text.ParseException
Parses the specified String in ISO 8601 day format (yyyy-MM-dd) into a Java Date. This is also the SQL Date format.

Parameters:
date - - The input date that is to be parsed.
Returns:
Date - The formatted string value.
Throws:
java.text.ParseException - - If an exception is encountered while attempting to parse the input String in yyyy-MM-dd format into a Java Date.

getTime

public java.lang.String getTime(java.util.Date date)
Formats the specified Date object in ISO 8601 time format (HH:mm:ss). This is also the SQL Time format.

Parameters:
date - - The input date that is to be formatted.
Returns:
String - The formatted string value.

getTime

public java.util.Date getTime(java.lang.String date)
                       throws java.text.ParseException
Parses the specified String object in ISO 8601 time format (HH:mm:ss) into a Java Date. This is also the SQL Time format.

Parameters:
date - - The input date that is to be parsed.
Returns:
Date - The parsed date value.
Throws:
java.text.ParseException - - If an exception is encountered while attempting to parse the input String in HH-mm-ss format into a Java Date.

getDateTime

public java.lang.String getDateTime(java.util.Date date)
Formats the specified Date object in ISO 8601 date-time format (yyyy-MM-dd'T'HH-mm-ss'Z').

Note: This assumes that the input string is in UTC as indicated by the 'Z'.

Parameters:
date - - The input date that is to be formatted.
Returns:
String - The formatted string value.

getDateTime

public java.util.Date getDateTime(java.lang.String date)
                           throws java.text.ParseException
Parses the specified String object in ISO 8601 date-time format (yyyy-MM-dd'T'HH-mm-ss'Z') into a Java Date.

Note: This assumes that the input string is in UTC as indicated by the 'Z'.

Parameters:
date - - The input string that is to be formatted.
Returns:
Date - The parsed date value.
Throws:
java.text.ParseException

getSQLTimestamp

public java.lang.String getSQLTimestamp(java.util.Date date)
Formats the specified Date object in SQL timestamp format (yyyy-MM-dd HH-mm-ss).

Parameters:
date - - The input date that is to be formatted.
Returns:
String - The formatted string value.

getSQLTimestamp

public java.util.Date getSQLTimestamp(java.lang.String date)
                               throws java.text.ParseException
Parses the specified String object in SQL timestamp format (yyyy-MM-dd HH-mm-ss) into a Java Date.

Parameters:
date - - The input string that is to be formatted.
Returns:
Date - The parsed date value.
Throws:
java.text.ParseException

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan