Enum Class DateType

java.lang.Object
java.lang.Enum<DateType>
org.simpleframework.xml.transform.DateType
All Implemented Interfaces:
Serializable, Comparable<DateType>, Constable

enum DateType extends Enum<DateType>
The DateType enumeration provides a set of known date formats supported by the date transformer. This allows the XML representation of a date to come in several formats, from most accurate to least. Enumerating the dates ensures that resolution of the format is fast by enabling inspection of the date string.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    The DateFormat provides a synchronized means for using the simple date format object.

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    This is the default date format used by the date transform.
    This is the date type without millisecond resolution.
    This date type enables only the specific date to be used.
    This is the shortest format that relies on the date locale.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    This is the date formatter that is used to parse the date.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    DateType(String format)
    Constructor for the DateType enumeration.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Date
    This is used to convert the string to a date value.
    Acquires the date format from the date type.
    static String
    getText(Date date)
    This is used to convert the date to a string value.
    static DateType
    This is used to acquire a date type using the specified text as input.
    static DateType
    Returns the enum constant of this class with the specified name.
    static DateType[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • FULL

      public static final DateType FULL
      This is the default date format used by the date transform.
    • LONG

      public static final DateType LONG
      This is the date type without millisecond resolution.
    • NORMAL

      public static final DateType NORMAL
      This date type enables only the specific date to be used.
    • SHORT

      public static final DateType SHORT
      This is the shortest format that relies on the date locale.
  • Field Details

    • format

      private DateType.DateFormat format
      This is the date formatter that is used to parse the date.
  • Constructor Details

    • DateType

      private DateType(String format)
      Constructor for the DateType enumeration. This will accept a simple date format pattern, which is used to parse an input string and convert it to a usable date.
      Parameters:
      format - this is the format to use to parse the date
  • Method Details

    • values

      public static DateType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DateType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getFormat

      private DateType.DateFormat getFormat()
      Acquires the date format from the date type. This is then used to parse the date string and convert it to a usable date. The format returned is synchronized for safety.
      Returns:
      this returns the date format to be used
    • getText

      public static String getText(Date date) throws Exception
      This is used to convert the date to a string value. The string value can then be embedded in to the generated XML in such a way that it can be recovered as a Date when the value is transformed by the date transform.
      Parameters:
      date - this is the date that is converted to a string
      Returns:
      this returns the string to represent the date
      Throws:
      Exception
    • getDate

      public static Date getDate(String text) throws Exception
      This is used to convert the string to a date value. The date value can then be recovered from the generated XML by parsing the text with one of the known date formats. This allows bidirectional transformation of dates to strings.
      Parameters:
      text - this is the date that is converted to a date
      Returns:
      this returns the date parsed from the string value
      Throws:
      Exception
    • getType

      public static DateType getType(String text)
      This is used to acquire a date type using the specified text as input. This will perform some checks on the raw string to match it to the appropriate date type. Resolving the date type in this way ensures that only one date type needs to be used.
      Parameters:
      text - this is the text to be matched with a date type
      Returns:
      the most appropriate date type for the given string