Rakesh API

biz.wedoit4u.ejb.session
Interface DateFormatter

All Superinterfaces:
javax.ejb.EJBLocalObject

public interface DateFormatter
extends javax.ejb.EJBLocalObject

This stateless session bean provides utility methods to convert dates into commonly needed string formats, as well as strings in commonly used date formats into Java Dates.

For maximum efficiency this session bean is implemented only as a local EJB, and this interface represents the local interface to the bean.

The following code sample shows one way of using the methods in this session bean:

    Date now = new Date();
    String formattedDate = "";
    Date parsedDate = null;
    try
    {
      DateFormatter df = SessionBeanProvider.getDateFormatter();
      formattedDate = df.getDateTime( now );

      try
      {
        parsedDate = df.getDateTime( formattedDate );
      }
      catch ( ParseException pex )
      {
        // Do error processing
      }

      df.remove();
    }
    catch ( Exception ex )
    {
      // Do error processing.
    }
 

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

Copyright 2003, wedoit4u.biz

See Also:
SessionBeanProvider.getDateFormatter()

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).
 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) 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 interface javax.ejb.EJBLocalObject
getEJBLocalHome, getPrimaryKey, isIdentical, remove
 

Method Detail

getDay

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

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

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

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

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). This is not strictly ISO compliant, since this would indicate that the time is in zero meridian, while in reality this time is in US central time.

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

getDateTime

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) into a Java Date. This is not strictly ISO compliant, since this would indicate that the time is in zero meridian, while in reality this time is in US central time.

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

getSQLTimestamp

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

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