com.j256.ormlite.field.types
Class DateType

java.lang.Object
  extended by com.j256.ormlite.field.BaseFieldConverter
      extended by com.j256.ormlite.field.types.BaseDataType
          extended by com.j256.ormlite.field.types.BaseDateType
              extended by com.j256.ormlite.field.types.DateType
All Implemented Interfaces:
DataPersister, FieldConverter
Direct Known Subclasses:
SqlDateType, TimeStampType

public class DateType
extends BaseDateType

Type that persists a Date object.

NOTE: This is not the same as the Date class that is handled by SqlDateType.

Author:
graywatson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.j256.ormlite.field.types.BaseDateType
BaseDateType.DateStringFormatConfig
 
Field Summary
 
Fields inherited from class com.j256.ormlite.field.types.BaseDateType
defaultDateFormatConfig
 
Constructor Summary
protected DateType(SqlType sqlType, Class<?>[] classes)
           
 
Method Summary
protected  BaseDateType.DateStringFormatConfig getDefaultDateFormatConfig()
          Return the default date format configuration.
static DateType getSingleton()
           
 boolean isArgumentHolderRequired()
          Must use ArgumentHolder when querying for values of this type.
 Object javaToSqlArg(FieldType fieldType, Object javaObject)
          Convert a Java object and return the appropriate argument to a SQL insert or update statement.
 Object parseDefaultString(FieldType fieldType, String defaultStr)
          Convert a default string object and return the appropriate argument to a SQL insert or update statement.
 Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos)
          Return the SQL argument object extracted from the results associated with column in position columnPos.
 Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos)
          Return the object converted from the SQL arg to java.
 
Methods inherited from class com.j256.ormlite.field.types.BaseDateType
convertDateStringConfig, isValidForField, isValidForVersion, moveToNextValue, normalizeDateString, parseDateString
 
Methods inherited from class com.j256.ormlite.field.types.BaseDataType
convertIdNumber, dataIsEqual, generateId, getAssociatedClasses, getAssociatedClassNames, getDefaultWidth, getPrimaryClass, getSqlType, isAppropriateId, isComparable, isEscapedDefaultValue, isEscapedValue, isPrimitive, isSelfGeneratedId, isValidGeneratedType, makeConfigObject, resultStringToJava
 
Methods inherited from class com.j256.ormlite.field.BaseFieldConverter
isStreamType, resultToJava
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.j256.ormlite.field.FieldConverter
isStreamType, resultToJava
 

Constructor Detail

DateType

protected DateType(SqlType sqlType,
                   Class<?>[] classes)
Method Detail

getSingleton

public static DateType getSingleton()

parseDefaultString

public Object parseDefaultString(FieldType fieldType,
                                 String defaultStr)
                          throws SQLException
Description copied from interface: FieldConverter
Convert a default string object and return the appropriate argument to a SQL insert or update statement.

Specified by:
parseDefaultString in interface FieldConverter
Specified by:
parseDefaultString in class BaseDataType
Throws:
SQLException

resultToSqlArg

public Object resultToSqlArg(FieldType fieldType,
                             DatabaseResults results,
                             int columnPos)
                      throws SQLException
Description copied from interface: FieldConverter
Return the SQL argument object extracted from the results associated with column in position columnPos. For example, if the type is a date-long then this will return a long value or null.

Specified by:
resultToSqlArg in interface FieldConverter
Specified by:
resultToSqlArg in class BaseDataType
Parameters:
fieldType - Associated FieldType which may be null.
Throws:
SQLException - If there is a problem accessing the results data.

sqlArgToJava

public Object sqlArgToJava(FieldType fieldType,
                           Object sqlArg,
                           int columnPos)
Description copied from interface: FieldConverter
Return the object converted from the SQL arg to java. This takes the database representation and converts it into a Java object. For example, if the type is a date-long then this will take a long which is stored in the database and return a Date.

Specified by:
sqlArgToJava in interface FieldConverter
Overrides:
sqlArgToJava in class BaseFieldConverter
Parameters:
fieldType - Associated FieldType which may be null.
sqlArg - SQL argument converted with FieldConverter.resultToSqlArg(FieldType, DatabaseResults, int) which will not be null.

javaToSqlArg

public Object javaToSqlArg(FieldType fieldType,
                           Object javaObject)
Description copied from interface: FieldConverter
Convert a Java object and return the appropriate argument to a SQL insert or update statement.

Specified by:
javaToSqlArg in interface FieldConverter
Overrides:
javaToSqlArg in class BaseFieldConverter

isArgumentHolderRequired

public boolean isArgumentHolderRequired()
Description copied from interface: DataPersister
Must use ArgumentHolder when querying for values of this type.

Specified by:
isArgumentHolderRequired in interface DataPersister
Overrides:
isArgumentHolderRequired in class BaseDataType

getDefaultDateFormatConfig

protected BaseDateType.DateStringFormatConfig getDefaultDateFormatConfig()
Return the default date format configuration.



This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.