java.lang.Object
org.scopemvc.util.convertor.NullStringConvertor
org.scopemvc.util.convertor.DateStringConvertor
- All Implemented Interfaces:
- StringConvertor
- Direct Known Subclasses:
- DateTimeStringConvertor, TimeStringConvertor
- public class DateStringConvertor
- extends NullStringConvertor
String convertor for type java.util.Date. The Time part
of Date instances are ignored. See
DateTimeStringConvertor and
TimeStringConvertor.
It uses one java.text.DateFormat for converting
into String and set of DateFormats for
parsing. Parsing formats are successively used to try to parse until
one is successful.
Formats are picked up from config (see
org.scopemvc.util.DefaultScopeConfig for details)
or if none in config, the default formatter is:
DateFormat.getDateInstance(DateFormat.MEDIUM)
and default parsers are:
DateFormat.getDateInstance(DateFormat.FULL);
DateFormat.getDateInstance(DateFormat.LONG);
DateFormat.getDateInstance(DateFormat.MEDIUM);
DateFormat.getDateInstance(DateFormat.SHORT);
Note: the default parsing set is initialized during class loading
and based on default platform locale. If application uses other locales,
there will be need to set parsing objects explicitly.
- Version:
- $Revision: 1.5 $ $Date: 2002/01/26 09:46:20 $
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
private static final org.apache.commons.logging.Log LOG
formatter
private java.text.DateFormat formatter
parsers
private java.text.DateFormat[] parsers
defaultParsers
private static final java.text.DateFormat[] defaultParsers
DateStringConvertor
public DateStringConvertor()
- Creates new DateStringConvertor. If formats and parsers
are specified in config then use those else use current locale default
format and platform locale default parsers.
DateStringConvertor
public DateStringConvertor(java.text.DateFormat inFormatter,
java.text.DateFormat[] inParsers)
- Creates new DateStringConvertor with specified formatter and parsers.
initDefaults
protected void initDefaults()
getDefaultParsers
protected java.text.DateFormat[] getDefaultParsers()
setFormatter
public final void setFormatter(java.lang.Object inFormat)
- Sets format used by this convertor for converting
Dates into Strings.
setParsers
public final void setParsers(java.lang.Object[] inParsers)
- Set parser array for this converter.
stringAsValue
public java.lang.Object stringAsValue(java.lang.String inString)
throws java.lang.IllegalArgumentException
- Returns instance of
java.util.Date.Parsing formats
are successively used to try to parse until one is successful
or exception is thrown.
Empty, null and getNullAsString() 55 strings are converted into null.
valueAsString
public java.lang.String valueAsString(java.lang.Object inValue)
throws java.lang.IllegalArgumentException
- Description copied from interface:
StringConvertor
- Formats object into
String. It never return a null.
Implementing class can offer posibility to set string representation
of null (such as "null" or
""), however default representation should be
"". Slightly different null handling is performed
in StringStringConvertor class.