com.ds.fw.types.formatter
Class FwDateFormatter

java.lang.Object
  |
  +--com.ds.fw.types.formatter.FwDateFormatter

public class FwDateFormatter
extends java.lang.Object

Support the formatting and parsing of dates in text fields. New feature support depending on Locale dates formatting and parsing getting date format form Resource file by com.ds.fw.resources.FwResourceTable. Valid formats are: mmdd mmddyy ccyymmdd m/d m/dd mm/d mm/dd m/d/yy m/d/ccyy m/dd/yy m/dd/ccyy mm/d/yy mm/d/ccyy mm/dd/yy mm/dd/ccyy MMMd MMMdd MMM d MMM dd dMMM ddMMM d MMM dd MMM MMM d yy MMM d ccyy MMM dd yy MMM dd ccyy MMMddyy d.m d.mm dd.m dd.mm d.m.yy d.m.ccyy d.mm.yy d.mm.ccyy dd.m.yy dd.m.ccyy dd.mm.yy dd.mm.ccyy

See Also:
FwResourceTable

Field Summary
static java.lang.String DATE_FORMAT_PATTERN
           
static java.lang.String[] MONTH_NAMES
           
static java.lang.String TIME_FORMAT_PATTERN
           
 
Constructor Summary
FwDateFormatter()
           
 
Method Summary
 int asInt(java.lang.String s)
          Parse a string and return it as int
static java.util.Date getDataFrom(java.lang.Object o)
           
static java.lang.String getDataString(java.util.Date da)
           
 com.ds.fw.types.data.FwDateIF getDateFor(int mm, int dd)
          Gets the date by given month and day
 com.ds.fw.types.data.FwDateIF getDateFor(int yy, int mm, int dd)
          Gets the date by given year, month and day
 com.ds.fw.types.data.FwDateIF getDateFor(int yy, java.lang.String mmm, int dd)
          Gets the date by given year , month and day
 com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String s)
          getDateFor(@see #String s); method must be remove.
 com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String mmm, int dd)
          Gets the date by given month and day
 com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String dateString, java.util.Locale inLocale)
          getDateFor method return @see #Date holds in @see #String dateString parameter depending on location.
 int getMonthFor(java.lang.String s)
          Gets the month number
static java.lang.String getStringFrom(java.util.Date da)
           
static java.lang.String getTimeString(java.util.Date da)
           
static java.lang.String toStringValue(com.ds.fw.types.data.FwDateIF date, java.util.Locale loc)
          toStingValue() method return corectly formatted string for given location
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MONTH_NAMES

public static java.lang.String[] MONTH_NAMES

DATE_FORMAT_PATTERN

public static java.lang.String DATE_FORMAT_PATTERN

TIME_FORMAT_PATTERN

public static java.lang.String TIME_FORMAT_PATTERN
Constructor Detail

FwDateFormatter

public FwDateFormatter()
Method Detail

toStringValue

public static java.lang.String toStringValue(com.ds.fw.types.data.FwDateIF date,
                                             java.util.Locale loc)
toStingValue() method return corectly formatted string for given location

Parameters:
date - date for format
loc - Location - default Location is Locale.US In case no date in string date return empty string.
See Also:
FwDateIF

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String dateString,
                                                java.util.Locale inLocale)
getDateFor method return @see #Date holds in @see #String dateString parameter depending on location. @see #Locale inLocale


getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String s)
getDateFor(@see #String s); method must be remove. It is overriden by @see #getDateFor(String, Locale inLocale);


getMonthFor

public int getMonthFor(java.lang.String s)
Gets the month number

Parameters:
s - - the month name
Returns:
the month number(from 0 to 11), -1 if there is no month with such name

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String mmm,
                                                int dd)
Gets the date by given month and day

Parameters:
mmm - - the month as string
dd - - the day
Returns:
the date

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(int yy,
                                                java.lang.String mmm,
                                                int dd)
Gets the date by given year , month and day

Parameters:
yy - - the year
mmm - - the month, given as string
dd - - the day
Returns:
the date

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(int mm,
                                                int dd)
Gets the date by given month and day

Parameters:
mm - - the month
dd - - the day
Returns:
the date

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(int yy,
                                                int mm,
                                                int dd)
Gets the date by given year, month and day

Parameters:
yy - - the year
mm - - the month
dd - - the day
Returns:
the date

asInt

public int asInt(java.lang.String s)
Parse a string and return it as int

Parameters:
s - - the string which is parsed
Returns:
the string as int or -1 if it can be parsed

getDataFrom

public static java.util.Date getDataFrom(java.lang.Object o)

getStringFrom

public static java.lang.String getStringFrom(java.util.Date da)

getTimeString

public static java.lang.String getTimeString(java.util.Date da)

getDataString

public static java.lang.String getDataString(java.util.Date da)