Package io.ebeaninternal.server.type
Class ScalarTypeBaseDate<T>
- java.lang.Object
-
- io.ebeaninternal.server.type.ScalarTypeBase<T>
-
- io.ebeaninternal.server.type.ScalarTypeBaseDate<T>
-
- All Implemented Interfaces:
StringFormatter
,StringParser
,ScalarDataReader<T>
,ScalarType<T>
- Direct Known Subclasses:
ScalarTypeDate
,ScalarTypeJodaDateMidnight
,ScalarTypeJodaLocalDate
,ScalarTypeLocalDate
,ScalarTypeUtilDate.DateType
,ScalarTypeYearMonthDate
public abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T>
Base class for Date types.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
bind(DataBind b, T value)
Convert (if necessary) and bind the value to the preparedStatement.abstract T
convertFromDate(Date ts)
Convert from java.sql.Date to the target Date type.T
convertFromMillis(long systemTimeMillis)
Convert the systemTimeMillis into the appropriate java object.abstract Date
convertToDate(T t)
Convert to java.sql.Date from the target Date type.abstract long
convertToMillis(T value)
Convert the target value to millis.String
formatValue(T t)
Convert the type into a string representation.DocPropertyType
getDocType()
Return the type this maps to for JSON document stores.boolean
isDateTimeCapable()
Return true if the type can accept long systemTimeMillis input.T
jsonRead(com.fasterxml.jackson.core.JsonParser parser)
Read the value from JsonParser.void
jsonWrite(com.fasterxml.jackson.core.JsonGenerator writer, T value)
Write the value to the JsonGenerator.T
parse(String value)
Convert the string value to the appropriate java object.T
read(DataReader dataReader)
Read the value from the resultSet and convert if necessary to the logical bean property value.T
readData(DataInput dataInput)
Read the value from binary input.void
writeData(DataOutput dataOutput, T value)
Write the value to binary output.-
Methods inherited from class io.ebeaninternal.server.type.ScalarTypeBase
asVersion, format, getJdbcType, getLength, getType, isBinaryType, isDirty, isJdbcNative, isMutable, loadIgnore
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.ebeaninternal.server.type.ScalarType
toBeanType, toJdbcType
-
-
-
-
Method Detail
-
convertToMillis
public abstract long convertToMillis(T value)
Convert the target value to millis.
-
convertToDate
public abstract Date convertToDate(T t)
Convert to java.sql.Date from the target Date type.
-
convertFromDate
public abstract T convertFromDate(Date ts)
Convert from java.sql.Date to the target Date type.
-
bind
public void bind(DataBind b, T value) throws SQLException
Description copied from interface:ScalarType
Convert (if necessary) and bind the value to the preparedStatement.value may need to be converted from the logical bean property type to the JDBC type.
- Throws:
SQLException
-
read
public T read(DataReader dataReader) throws SQLException
Description copied from interface:ScalarType
Read the value from the resultSet and convert if necessary to the logical bean property value.- Throws:
SQLException
-
formatValue
public String formatValue(T t)
Description copied from interface:ScalarType
Convert the type into a string representation.Reciprocal of parse().
-
parse
public T parse(String value)
Description copied from interface:ScalarType
Convert the string value to the appropriate java object.Mostly used to support CSV, JSON and XML parsing.
Reciprocal of formatValue().
-
convertFromMillis
public T convertFromMillis(long systemTimeMillis)
Description copied from interface:ScalarType
Convert the systemTimeMillis into the appropriate java object.For non dateTime types this will throw an exception.
-
isDateTimeCapable
public boolean isDateTimeCapable()
Description copied from interface:ScalarType
Return true if the type can accept long systemTimeMillis input.This is used to determine if is is sensible to use the
ScalarType.convertFromMillis(long)
method.This includes the Date, Calendar, sql Date, Time, Timestamp, JODA types as well as Long, BigDecimal and String (although it generally is not expected to parse systemTimeMillis to a String or BigDecimal).
-
jsonRead
public T jsonRead(com.fasterxml.jackson.core.JsonParser parser) throws IOException
Description copied from interface:ScalarType
Read the value from JsonParser.- Throws:
IOException
-
jsonWrite
public void jsonWrite(com.fasterxml.jackson.core.JsonGenerator writer, T value) throws IOException
Description copied from interface:ScalarType
Write the value to the JsonGenerator.- Throws:
IOException
-
getDocType
public DocPropertyType getDocType()
Description copied from interface:ScalarType
Return the type this maps to for JSON document stores.
-
readData
public T readData(DataInput dataInput) throws IOException
Description copied from interface:ScalarType
Read the value from binary input.- Throws:
IOException
-
writeData
public void writeData(DataOutput dataOutput, T value) throws IOException
Description copied from interface:ScalarType
Write the value to binary output.- Throws:
IOException
-
-