Class DateToStringConverter

  • All Implemented Interfaces:
    Converter<java.util.Date,​java.lang.String>

    public class DateToStringConverter
    extends java.lang.Object
    implements Converter<java.util.Date,​java.lang.String>
    Converts instances of Date to String. This class is thread-safe.
    Author:
    Eric Nielsen
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canConvert​(java.lang.Class sourceClass, java.lang.Class destinationClass)
      Returns true if this converter can convert instances of sourceClass to destinationClass.
      java.lang.String convert​(java.util.Date source)
      Converts instance of S to T.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DateToStringConverter

        public DateToStringConverter​(java.lang.String pattern)
        Parameters:
        pattern - pattern to use for conversion
      • DateToStringConverter

        public DateToStringConverter​(java.text.DateFormat format)
        Parameters:
        format - DateFormat to use for conversion
    • Method Detail

      • canConvert

        public boolean canConvert​(java.lang.Class sourceClass,
                                  java.lang.Class destinationClass)
        Description copied from interface: Converter
        Returns true if this converter can convert instances of sourceClass to destinationClass.
        Specified by:
        canConvert in interface Converter<java.util.Date,​java.lang.String>
        Parameters:
        sourceClass - source Class
        destinationClass - destination Class
        Returns:
        true if sourceClass is java.util.Date, or a subclass of it, and destinationClass is String
      • convert

        public java.lang.String convert​(java.util.Date source)
        Description copied from interface: Converter
        Converts instance of S to T.
        Specified by:
        convert in interface Converter<java.util.Date,​java.lang.String>
        Parameters:
        source - instance of java.util.Date, or subclasses of it, for example: java.sql.Date, java.sql.Time, java.sql.Timestamp
        Returns:
        source converted to String