com.arunta.base.util
Class DateTimeFormatter

java.lang.Object
  extended by com.arunta.base.util.DateTimeFormatter

public class DateTimeFormatter
extends java.lang.Object

A collection of date and time utilities.


Constructor Summary
DateTimeFormatter()
           
 
Method Summary
static java.util.Date getDate(java.lang.String date)
          Converst a string in the yyyy.MM.dd format to a date object.
static java.util.Date getDate(java.lang.String date, java.lang.String time)
          Combines string in the yyyy.MM.dd and HH:mm:ss format and converts teh combination to a date object.
static java.lang.String getFormattedDate(java.util.Date date, boolean useGMT)
          Formats the date part only.
static java.lang.String getFormattedDateTime(java.util.Date date, boolean useGMT)
          Formats the date and time parts.
static java.lang.String getFormattedTime(java.util.Date date, boolean useGMT)
          Formats the time part only.
static java.lang.String getPrintableDate(java.lang.String date)
          Converts a date in the yyyy.MM.dd format to a format suitable to display.
static java.text.DateFormat getPrintableDateFormat()
           
static java.lang.String getPrintableDateTime(java.util.Date date)
          Converts the date to a format suitable to display.
static java.util.Date parseDateTime(java.lang.String dateTime)
          Converst a string in the yyyy.MM.dd HH:mm:ss format to a date object.
static void setPrintableDateFormat(java.text.DateFormat dateFormat)
          Sets the date and time formater which should be used to format date and time in order to display it.
static void timeZoneChanged()
          Reinitialises various date and time formaters with the new time zone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTimeFormatter

public DateTimeFormatter()
Method Detail

timeZoneChanged

public static void timeZoneChanged()
Reinitialises various date and time formaters with the new time zone.


getPrintableDateFormat

public static java.text.DateFormat getPrintableDateFormat()
Returns:
Returns the date and time formater that should be used to format date and time in order to display it.

setPrintableDateFormat

public static void setPrintableDateFormat(java.text.DateFormat dateFormat)
Sets the date and time formater which should be used to format date and time in order to display it.

Parameters:
dateFormat - An instance of a date and time formater.

getPrintableDate

public static java.lang.String getPrintableDate(java.lang.String date)
Converts a date in the yyyy.MM.dd format to a format suitable to display.

Parameters:
date - The date to format.
Returns:
String representing the date that can be displayed.

getPrintableDateTime

public static java.lang.String getPrintableDateTime(java.util.Date date)
Converts the date to a format suitable to display.

Parameters:
date - The date to format.
Returns:
String representing the date that can be displayed.

getFormattedDate

public static java.lang.String getFormattedDate(java.util.Date date,
                                                boolean useGMT)
Formats the date part only.

Parameters:
date - The date to format.
useGMT - Set this flag to true to use the GMT formater.
Returns:
String in the yyyy.MM.dd format of the useGMT flag is set to false. Otherwise, string in the yyy-MM-dd format.

getFormattedTime

public static java.lang.String getFormattedTime(java.util.Date date,
                                                boolean useGMT)
Formats the time part only.

Parameters:
date - The date to format.
useGMT - Set this flag to true to use the GMT formater.
Returns:
String in the HH:mm:ss format.

getFormattedDateTime

public static java.lang.String getFormattedDateTime(java.util.Date date,
                                                    boolean useGMT)
Formats the date and time parts.

Parameters:
date - The date to format.
useGMT - Set this flag to true to use the GMT formater.
Returns:
String in the yyyy.MM.dd HH:mm:ss format of the useGMT flag is set to false. Otherwise, string in the yyy-MM-dd HH:mm:ss format.

getDate

public static java.util.Date getDate(java.lang.String date)
Converst a string in the yyyy.MM.dd format to a date object.

Parameters:
date - A string in the yyyy.MM.dd format.
Returns:
A date object or null if the date can not be extracetd from the string.

getDate

public static java.util.Date getDate(java.lang.String date,
                                     java.lang.String time)
Combines string in the yyyy.MM.dd and HH:mm:ss format and converts teh combination to a date object.

Parameters:
date - A string in the yyyy.MM.dd format.
time - A string in the HH:mm:ss format.
Returns:
A date object or null if the date can not be extracetd from the string.

parseDateTime

public static java.util.Date parseDateTime(java.lang.String dateTime)
Converst a string in the yyyy.MM.dd HH:mm:ss format to a date object.

Parameters:
dateTime - A string in the yyyy.MM.dd HH:mm:ss format.
Returns:
A date object or null if the date can not be extracetd from the string.


Copyright ©, 2005-2012 Prolancer Pty Ltd, Sydney Australia.