Class StringToTimestampConverter

  • All Implemented Interfaces:
    Converter<java.lang.String,​java.sql.Timestamp>

    public class StringToTimestampConverter
    extends ConverterAdapter<java.lang.String,​java.sql.Timestamp>
    Converts instances of String to Timestamp. This class is thread-safe.
    Author:
    Eric Nielsen
    • Constructor Detail

      • StringToTimestampConverter

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

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

      • sourceClass

        protected java.lang.Class<java.lang.String> sourceClass()
        Specified by:
        sourceClass in class ConverterAdapter<java.lang.String,​java.sql.Timestamp>
      • destinationClass

        protected java.lang.Class<java.sql.Timestamp> destinationClass()
        Specified by:
        destinationClass in class ConverterAdapter<java.lang.String,​java.sql.Timestamp>
      • doConvert

        public java.sql.Timestamp doConvert​(java.lang.String source)
                                     throws java.text.ParseException
        Description copied from class: ConverterAdapter
        Converts instance of S to T.
        Specified by:
        doConvert in class ConverterAdapter<java.lang.String,​java.sql.Timestamp>
        Parameters:
        source - instance of String or null
        Returns:
        source converted to java.sql.Timestamp, or null if source is blank
        Throws:
        java.text.ParseException - if conversion failed