Class SimpleDateFormatParser

  • All Implemented Interfaces:
    Serializable, Cloneable, DataFilter, DataSource, DataTarget

    public class SimpleDateFormatParser
    extends DateFormatParser
    Parses a String into a java.util.Date. The string is read from the given datasource and then parsed by the dateformat contained in this FormatParser.

    If the object read from the datasource is no string, the value is converted to string using String.valueOf (Object)

    This implementation uses a SimpleDateFormat and grants more control over the parsing results.

    Author:
    Thomas Morgner
    See Also:
    SimpleDateFormat, Serialized Form
    • Constructor Detail

      • SimpleDateFormatParser

        public SimpleDateFormatParser()
        DefaultConstructor.
    • Method Detail

      • getSimpleDateFormat

        public SimpleDateFormat getSimpleDateFormat()
        Returns the SimpleDateFormat object used in this parser.
        Returns:
        The date format object.
      • setSimpleDateFormat

        public void setSimpleDateFormat​(SimpleDateFormat format)
        Sets the date format for the parser.
        Parameters:
        format - The format.
        Throws:
        NullPointerException - if the format given is null
      • getFormatString

        public String getFormatString()
        Returns the formatString for this SimpleDateFormat. For a more detailed explaination of SimpleDateFormat formatstrings see java.text.SimpleDateFormat.
        Returns:
        the formatstring used for this DateFormat.
        See Also:
        SimpleDateFormat
      • setFormatString

        public void setFormatString​(String format)
        defines the formatString for this SimpleDateFormat.
        Parameters:
        format - the formatString
        Throws:
        IllegalArgumentException - if the string is invalid
      • getLocalizedFormatString

        public String getLocalizedFormatString()
        Returns a localized formatString for this SimpleDateFormat. For a more detailed explaination of SimpleDateFormat formatstrings see java.text.SimpleDateFormat.
        Returns:
        the localized format string.
        See Also:
        SimpleDateFormat
      • setLocalizedFormatString

        public void setLocalizedFormatString​(String format)
        defines the localized formatString for this SimpleDateFormat.
        Parameters:
        format - the formatString
        Throws:
        IllegalArgumentException - if the string is invalid
      • isKeepState

        public boolean isKeepState()
        Defines, whether the filter should keep its state, if a locale change is detected. This will effectivly disable the locale update.
        Returns:
        true, if the locale should not update the DateSymbols, false otherwise.
      • setKeepState

        public void setKeepState​(boolean keepState)
        Defines, whether the filter should keep its state, if a locale change is detected. This will effectivly disable the locale update.
        Parameters:
        keepState - set to true, if the locale should not update the DateSymbols, false otherwise.
      • getValue

        public Object getValue​(ExpressionRuntime runtime,
                               ReportElement element)
        Returns the formatted string. The value is read using the data source given and formated using the formatter of this object. The formating is guaranteed to completly form the object to an string or to return the defined NullValue.

        If format, datasource or object are null, the NullValue is returned.

        Specified by:
        getValue in interface DataSource
        Overrides:
        getValue in class DateFormatParser
        Parameters:
        runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
        element -
        Returns:
        The formatted value.