public class SimpleDateCodec extends TypeCodec.PrimitiveIntCodec
TypeCodec
that maps CQL dates to Java primitive ints,
representing the number of days since the Epoch.
This codec can serve as a replacement for the driver's built-in
date
codec,
when application code prefers to deal with raw days than with
LocalDate
instances.
Important: this codec cannot work with SimpleStatement
s!
If you try to insert CQL date values as int
s in a SimpleStatement
,
the insertion would succeed but the values wouldn't be properly encoded.
Always use PreparedStatement
s when using this codec.
TypeCodec.AbstractCollectionCodec<E,C extends Collection<E>>, TypeCodec.AbstractMapCodec<K,V>, TypeCodec.AbstractTupleCodec<T>, TypeCodec.AbstractUDTCodec<T>, TypeCodec.PrimitiveBooleanCodec, TypeCodec.PrimitiveByteCodec, TypeCodec.PrimitiveDoubleCodec, TypeCodec.PrimitiveFloatCodec, TypeCodec.PrimitiveIntCodec, TypeCodec.PrimitiveLongCodec, TypeCodec.PrimitiveShortCodec
Modifier and Type | Field and Description |
---|---|
static SimpleDateCodec |
instance |
Constructor and Description |
---|
SimpleDateCodec() |
Modifier and Type | Method and Description |
---|---|
int |
deserializeNoBoxing(ByteBuffer bytes,
ProtocolVersion protocolVersion) |
String |
format(Integer value)
Format the given value as a valid CQL literal according
to the CQL type handled by this codec.
|
Integer |
parse(String value)
Parse the given CQL literal into an instance of the Java type
handled by this codec.
|
ByteBuffer |
serializeNoBoxing(int value,
ProtocolVersion protocolVersion) |
deserialize, serialize
accepts, accepts, accepts, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, getCqlType, getJavaType, inet, list, map, set, smallInt, time, timestamp, timeUUID, tinyInt, toString, tuple, userType, uuid, varchar, varint
public static final SimpleDateCodec instance
public ByteBuffer serializeNoBoxing(int value, ProtocolVersion protocolVersion)
serializeNoBoxing
in class TypeCodec.PrimitiveIntCodec
public int deserializeNoBoxing(ByteBuffer bytes, ProtocolVersion protocolVersion)
deserializeNoBoxing
in class TypeCodec.PrimitiveIntCodec
public Integer parse(String value)
TypeCodec
"NULL"
;
in most cases, implementations should interpret these inputs has equivalent to a null
reference.public String format(Integer value)
TypeCodec
"NULL"
for null
inputs.Copyright © 2012–2015. All rights reserved.