Class DateStringConverter

java.lang.Object
org.datanucleus.store.types.converters.DateStringConverter
All Implemented Interfaces:
Serializable, ColumnLengthDefiningTypeConverter, TypeConverter<Date,String>

public class DateStringConverter extends Object implements TypeConverter<Date,String>, ColumnLengthDefiningTypeConverter
Class to handle the conversion between java.util.Date and a String form. Uses java.time.Instant as an intermediary. Results in a String form like "2021-08-17T09:19:01.585Z".
See Also:
  • Field Details

  • Constructor Details

    • DateStringConverter

      public DateStringConverter()
  • Method Details

    • getDefaultColumnLength

      public int getDefaultColumnLength(int columnPosition)
      Description copied from interface: ColumnLengthDefiningTypeConverter
      Accessor for the default column length to use for the datastore column at the specified position.
      Specified by:
      getDefaultColumnLength in interface ColumnLengthDefiningTypeConverter
      Parameters:
      columnPosition - Position of the column being enquired about (0 = first)
      Returns:
      The column length (-1 if no preference)
    • toMemberType

      public Date toMemberType(String str)
      Description copied from interface: TypeConverter
      Method to convert the passed datastore value to the member type.
      Specified by:
      toMemberType in interface TypeConverter<Date,String>
      Parameters:
      str - Value from the datastore
      Returns:
      Value for the member
    • toDatastoreType

      public String toDatastoreType(Date date)
      Description copied from interface: TypeConverter
      Method to convert the passed member value to the datastore type.
      Specified by:
      toDatastoreType in interface TypeConverter<Date,String>
      Parameters:
      date - Value from the member
      Returns:
      Value for the datastore