Class 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 appropriate DateFormat 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 like SHORT or FULL. While the style for the date component is set by the inherited style 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 Detail

    • Constructor Detail

      • DateTimeTransformer

        public DateTimeTransformer()
        Creates a new instance of DateTimeTransformer.
    • 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 by java.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 of DateFormat.
        Specified by:
        createFormat in class DateTransformerBase
        Parameters:
        locale - the locale
        style - the style for the date portion
        config - the configuration with the properties
        Returns:
        the format object