Class DateToStringConverter

java.lang.Object
org.javalite.conversion.DateToStringConverter
All Implemented Interfaces:
Converter<Date,​String>

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

    • DateToStringConverter

      public DateToStringConverter(String pattern)
      Parameters:
      pattern - pattern to use for conversion
    • DateToStringConverter

      public DateToStringConverter(DateFormat format)
      Parameters:
      format - DateFormat to use for conversion
  • Method Details

    • canConvert

      public boolean canConvert(Class sourceClass, 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<Date,​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 String convert(Date source)
      Description copied from interface: Converter
      Converts instance of S to T.
      Specified by:
      convert in interface Converter<Date,​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