Class DateEditor

  • All Implemented Interfaces:
    java.beans.PropertyEditor, PropertyEditor<java.util.Date>

    public class DateEditor
    extends PropertyEditorSupport<java.util.Date>
    A property editor for Date.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.text.DateFormat[] formats
      The formats to use when parsing the string date
      private java.lang.String text
      Keep the text version of the date
    • Constructor Summary

      Constructors 
      Constructor Description
      DateEditor()  
    • Field Detail

      • formats

        private static java.text.DateFormat[] formats
        The formats to use when parsing the string date
      • text

        private java.lang.String text
        Keep the text version of the date
    • Constructor Detail

      • DateEditor

        public DateEditor()
    • Method Detail

      • initialize

        public static void initialize()
        Setup the parsing formats. Offered as a separate static method to allow testing of locale changes, since SimpleDateFormat will use the default locale upon construction. Should not be normally used!
      • setValue

        public void setValue​(java.lang.Object value)
        Sets directly the java.util.Date value
        Specified by:
        setValue in interface java.beans.PropertyEditor
        Specified by:
        setValue in interface PropertyEditor<java.util.Date>
        Overrides:
        setValue in class PropertyEditorSupport<java.util.Date>
        Parameters:
        value - a java.util.Date
      • setAsText

        public void setAsText​(java.lang.String text)
        Parse the text into a java.util.Date by trying one by one the registered DateFormat(s).
        Specified by:
        setAsText in interface java.beans.PropertyEditor
        Specified by:
        setAsText in interface PropertyEditor<java.util.Date>
        Specified by:
        setAsText in class PropertyEditorSupport<java.util.Date>
        Parameters:
        text - the string date
      • getAsText

        public java.lang.String getAsText()
        Returns either the cached string date, or the stored java.util.Date instance formated to string using the last of the registered DateFormat(s)
        Specified by:
        getAsText in interface java.beans.PropertyEditor
        Specified by:
        getAsText in interface PropertyEditor<java.util.Date>
        Overrides:
        getAsText in class PropertyEditorSupport<java.util.Date>
        Returns:
        date as string