Class DateConverter

    • Constructor Detail

      • DateConverter

        public DateConverter()
        Creates a DateConverter.
    • Method Detail

      • toString

        public java.lang.String toString​(java.lang.Object object,
                                         ConverterContext context)
        Converts the object to String. The object can be a Calendar, a Date or a Number. As long as the DateFormat can format it correctly, it will be converted to a String. If the object is already a String, we will return it directly as it is.
        Specified by:
        toString in interface ObjectConverter
        Parameters:
        object - the object to be converted
        context - the converter context.
        Returns:
        the string
      • supportToString

        public boolean supportToString​(java.lang.Object object,
                                       ConverterContext context)
        Description copied from interface: ObjectConverter
        If it supports toString method.
        Specified by:
        supportToString in interface ObjectConverter
        Parameters:
        object - object to be converted
        context - converter context to be used
        Returns:
        true if supports toString
      • fromString

        public java.lang.Object fromString​(java.lang.String string,
                                           ConverterContext context)
        Converts from a String to a Date.
        Specified by:
        fromString in interface ObjectConverter
        Parameters:
        string - the string to be converted.
        context - the context. It could be DATETIME_CONTEXT, DATE_CONTEXT or TIME_CONTEXT.
        Returns:
        the Date. If the string is null or empty, null will be returned. If the string cannot be parsed as a date, the string itself will be returned.
      • supportFromString

        public boolean supportFromString​(java.lang.String string,
                                         ConverterContext context)
        Description copied from interface: ObjectConverter
        If it supports fromString.
        Specified by:
        supportFromString in interface ObjectConverter
        Parameters:
        string - the string
        context - context to be converted
        Returns:
        true if it supports
      • getDefaultFormat

        public java.text.DateFormat getDefaultFormat()
        Gets DefaultFormat to format an calendar.
        Returns:
        DefaultFormat
      • setDefaultFormat

        public void setDefaultFormat​(java.text.DateFormat defaultFormat)
        Sets DefaultFormat to format an calendar.
        Parameters:
        defaultFormat - the new default date format
      • getDefaultTimeFormat

        public java.text.DateFormat getDefaultTimeFormat()
        Gets DefaultTimeFormat to format an calendar. This is used only when context is TIME_CONTEXT.
        Returns:
        DefaultTimeFormat
      • setDefaultTimeFormat

        public void setDefaultTimeFormat​(java.text.DateFormat defaultTimeFormat)
        Sets DefaultTimeFormat to format an calendar. This is used only when context is TIME_CONTEXT.
        Parameters:
        defaultTimeFormat - the new default time format
      • getDefaultDatetimeFormat

        public java.text.DateFormat getDefaultDatetimeFormat()
        Gets DefaultDatetimeFormat to format an calendar. This is used only when context is DATETIME_CONTEXT.
        Returns:
        DefaultDatetimeFormat
      • setDefaultDatetimeFormat

        public void setDefaultDatetimeFormat​(java.text.DateFormat defaultDatetimeFormat)
        Sets DefaultDatetimeFormat to format an calendar. This is used only when context is DATETIME_CONTEXT.
        Parameters:
        defaultDatetimeFormat - the new defaultdatetime format