com.ds.fw.types.formatter
Class FwExpirationDateFormatter

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

public class FwExpirationDateFormatter
extends java.lang.Object

Support the formatting and parsing of dates in text fields. Valid formats are: mmyy m/yy m/ccyy mm/yy mm/ccyy mmm yy mmm ccyy


Field Summary
static java.lang.String[] MONTH_NAMES
          An array containing the short names of the months
 
Constructor Summary
FwExpirationDateFormatter()
           
 
Method Summary
 int asInt(java.lang.String s)
          Transform a string (given as parameter) to int
 com.ds.fw.types.data.FwDateIF getDateFor(int yy, int mm)
          Gets the date by a given year and month number(from 1 to 12)
 com.ds.fw.types.data.FwDateIF getDateFor(int yy, java.lang.String mmm)
          Gets the date by a given year and a short name of a month
 com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String s)
          Constructs a FwDate object from a given string
 int getMonthFor(java.lang.String s)
          Gets the month number (from 0 to 11) by the short name of the month
static java.lang.String toStringValue(com.ds.fw.types.data.FwDateIF date, java.util.Locale loc)
          Gets the string representation of a date
 
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
An array containing the short names of the months

Constructor Detail

FwExpirationDateFormatter

public FwExpirationDateFormatter()
Method Detail

toStringValue

public static java.lang.String toStringValue(com.ds.fw.types.data.FwDateIF date,
                                             java.util.Locale loc)
Gets the string representation of a date

Parameters:
date - - the date
loc - - this parameter is not used in the code of the method
Returns:
a string representation of the date in format month/year

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(java.lang.String s)
Constructs a FwDate object from a given string

Parameters:
s - - the string we want to parse
Returns:
the date , null if the given string does not represent a valid date

getMonthFor

public int getMonthFor(java.lang.String s)
Gets the month number (from 0 to 11) by the short name of the month

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

getDateFor

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

Parameters:
yy - - the year
mmm - - the month's short name
Returns:
the date

getDateFor

public com.ds.fw.types.data.FwDateIF getDateFor(int yy,
                                                int mm)
Gets the date by a given year and month number(from 1 to 12)

Parameters:
yy - - the year
mm - - the month number (from 1 to 12)
Returns:
the date

asInt

public int asInt(java.lang.String s)
Transform a string (given as parameter) to int

Parameters:
s - - the string we want to transform
Returns:
the int value of the string , -1 if it can't be parsed