Class DateConverter
java.lang.Object
com.twelvemonkeys.util.convert.NumberConverter
com.twelvemonkeys.util.convert.DateConverter
- All Implemented Interfaces:
PropertyConverter
Converts strings to dates and back.
This class has a static cache of DateFormats, to avoid
creation and parsing of date formats every time one is used.
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/convert/DateConverter.java#2 $
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate DateFormatgetDateFormat(String pFormat) Converts the string to a date, using the given format for parsing.Converts the object to a string, using the given formatMethods inherited from class NumberConverter
getFormat
-
Constructor Details
-
DateConverter
public DateConverter()Creates aDateConverter
-
-
Method Details
-
toObject
Converts the string to a date, using the given format for parsing.- Specified by:
toObjectin interfacePropertyConverter- Overrides:
toObjectin classNumberConverter- Parameters:
pString- the string to convert.pType- the type to convert to.java.util.Dateand subclasses allowed.pFormat- the format used for parsing. Must be a legalSimpleDateFormatformat, ornullwhich will use the default format.- Returns:
- the object created from the given string. May safely be typecast
to
java.util.Date - Throws:
ConversionException- See Also:
-
toString
Converts the object to a string, using the given format- Specified by:
toStringin interfacePropertyConverter- Overrides:
toStringin classNumberConverter- Parameters:
pObject- the object to convert.pFormat- the format used for conversion. Must be a legalSimpleDateFormatformat, ornullwhich will use the default format.- Returns:
- the string representation of the object, on the correct format.
- Throws:
ConversionException- if the object is not a subclass ofjava.util.Date- See Also:
-
getDateFormat
-