com.scooterframework.common.util
Class DateUtil

java.lang.Object
  extended by com.scooterframework.common.util.DateUtil

public class DateUtil
extends java.lang.Object

DateUtil class has helper methods for rendering date and time.

Note: By the time of this version, the only allowed date-time patterns for automatic form processing are listed in description of getDateTimePattern(java.lang.String) method.


Constructor Summary
DateUtil()
           
 
Method Summary
static java.lang.String getDateTimePattern(java.lang.String dt)
          Returns a data time pattern string.
static java.util.Date parseDate(java.lang.String dateStr)
          Returns a date instance from a dateStr string.
static java.util.Date parseDate(java.lang.String dateStr, java.util.Locale locale)
          Returns a date instance from a dateStr string.
static java.util.Date parseDate(java.lang.String dateStr, java.lang.String pattern)
          Returns a date instance from a dateStr string.
static java.util.Date parseDate(java.lang.String dateStr, java.lang.String pattern, java.util.Locale locale)
          Returns a date instance from a dateStr string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Method Detail

parseDate

public static java.util.Date parseDate(java.lang.String dateStr)

Returns a date instance from a dateStr string. The date-time pattern needed for parsing will be detected from the input dateStr string with the current locale.

Note: By the time of this version, the only allowed date-time patterns for automatic form processing are listed in description of getDateTimePattern(java.lang.String) method.

Parameters:
dateStr - date string
Returns:
a date instance

parseDate

public static java.util.Date parseDate(java.lang.String dateStr,
                                       java.lang.String pattern)

Returns a date instance from a dateStr string.

Note: By the time of this version, the only allowed date-time patterns for automatic form processing are listed in description of getDateTimePattern(java.lang.String) method.

Parameters:
dateStr - date string
pattern - the pattern describing the date and time format
Returns:
a date instance

parseDate

public static java.util.Date parseDate(java.lang.String dateStr,
                                       java.util.Locale locale)

Returns a date instance from a dateStr string. The date-time pattern needed for parsing will be detected from the input dateStr string

Note: By the time of this version, the only allowed date-time patterns for automatic form processing are listed in description of getDateTimePattern(java.lang.String) method.

Parameters:
dateStr - date string
locale - locale for date
Returns:
a date instance

parseDate

public static java.util.Date parseDate(java.lang.String dateStr,
                                       java.lang.String pattern,
                                       java.util.Locale locale)

Returns a date instance from a dateStr string.

Note: By the time of this version, the only allowed date-time patterns for automatic form processing are listed in description of getDateTimePattern(java.lang.String) method.

Parameters:
dateStr - date string
pattern - the pattern describing the date and time format
locale - locale for date
Returns:
a date instance

getDateTimePattern

public static final java.lang.String getDateTimePattern(java.lang.String dt)
Returns a data time pattern string.
               slashDate: MM/dd/yyyy  or MM/dd/yy
                dashDate: yyyy-MM-dd
              hourMinute: HH:mm
        hourMinuteSecond: HH:mm:ss
   hourMinuteSecondMilli: HH:mm:ss.SSS
              dashDateHM: yyyy-MM-dd HH:mm
             dashDateHMS: yyyy-MM-dd HH:mm:ss
            dashDateHMSM: yyyy-MM-dd HH:mm:ss.SSS
             slashDateHM: MM/dd/yyyy HH:mm        or MM/dd/yy HH:mm
            slashDateHMS: MM/dd/yyyy HH:mm:ss     or MM/dd/yy HH:mm:ss
           slashDateHMSM: MM/dd/yyyy HH:mm:ss.SSS or MM/dd/yy HH:mm:ss.SSS
 

Parameters:
dt - a date time string
Returns:
a data time pattern string