Package net.sf.jguiraffe.transform
Class DateTimeTransformer
- java.lang.Object
-
- net.sf.jguiraffe.transform.DateTransformerBase
-
- net.sf.jguiraffe.transform.DateTimeTransformer
-
- All Implemented Interfaces:
Transformer
,Validator
public class DateTimeTransformer extends DateTransformerBase
A specialized transformer that transforms strings into date objects with both a date and time component.
This transformer class allows user to enter a date and a time in a single input field, such as
1/31/2008 10:19
. Most of the required functionality is already implemented by the base class. This class creates an appropriateDateFormat
object that supports parsing time stamps.For the documentation of the supported error messages refer to the super class. In addition to the properties defined by
DateTransformerBase
, the following properties can be set:Property Description Default timeStyle Defines the style of the time component. This can be one of the style constants declared by the java.text.DateFormat
class likeSHORT
orFULL
. While the style for the date component is set by the inheritedstyle
property, with this property the style for the time component can be set separately.SHORT - Version:
- $Id: DateTimeTransformer.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
PROP_TIME_STYLE
Constant for the time style property.-
Fields inherited from class net.sf.jguiraffe.transform.DateTransformerBase
PROP_AFTER, PROP_BEFORE, PROP_EQUAL, PROP_LENIENT, PROP_REFERENCE_DATE, PROP_STYLE
-
-
Constructor Summary
Constructors Constructor Description DateTimeTransformer()
Creates a new instance ofDateTimeTransformer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DateFormat
createFormat(Locale locale, int style, org.apache.commons.configuration.Configuration config)
Creates the format object to be used by this transformer.int
getTimeStyle()
Returns the style for the time portion.void
setTimeStyle(int timeStyle)
Sets the style for the time.-
Methods inherited from class net.sf.jguiraffe.transform.DateTransformerBase
errorResult, getDefaultReferenceDate, getReferenceDate, getReferenceDateProperty, getStyle, initializeFormat, isAfter, isBefore, isDateValid, isEqual, isLenient, isValid, setAfter, setBefore, setEqual, setLenient, setReferenceDate, setStyle, transform, transformDate, transformSqlDate, transformToDate, transformToString, updateDatePart, updateTimePart
-
-
-
-
Field Detail
-
PROP_TIME_STYLE
protected static final String PROP_TIME_STYLE
Constant for the time style property.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTimeStyle
public int getTimeStyle()
Returns the style for the time portion.- Returns:
- the style for the time
-
setTimeStyle
public void setTimeStyle(int timeStyle)
Sets the style for the time. The styles for the date portion and the time portion are separately set. Here one of the constants supported byjava.text.DateFormat
(e.g.SHORT
,MEDIUM
etc.) can be passed in.- Parameters:
timeStyle
- the style for the time
-
createFormat
protected DateFormat createFormat(Locale locale, int style, org.apache.commons.configuration.Configuration config)
Creates the format object to be used by this transformer. This implementation returns a date/time instance ofDateFormat
.- Specified by:
createFormat
in classDateTransformerBase
- Parameters:
locale
- the localestyle
- the style for the date portionconfig
- the configuration with the properties- Returns:
- the format object
-
-