Class LocalDateTimeField
java.lang.Object
io.datarouter.model.field.BaseField<T>
io.datarouter.model.field.BasePrimitiveField<LocalDateTime,LocalDateTimeFieldKey>
io.datarouter.model.field.imp.custom.LocalDateTimeField
- All Implemented Interfaces:
ByteEncodedField<LocalDateTime>,StringEncodedField<LocalDateTime>,Field<LocalDateTime>,Comparable<Field<LocalDateTime>>
public class LocalDateTimeField extends BasePrimitiveField<LocalDateTime,LocalDateTimeFieldKey>
LocalDateTime stores the value of nanoseconds in a range from 0 to 999,999,999.
However, the MySQL DATETIME column type cannot handle this level of granularity
(it can handle at most 6 digits of fractional seconds).
LocalDateTimeField defaults to a truncation of the LocalDateTime nanosecond value of up to 3 fractional seconds
as this corresponds to the fractional seconds granularity of System.currentTimeMillis() and LocalDateTime.now().
This is the recommended use, but can be overridden to store the full value.
A LocalDateTime object created using LocalDateTime::of might not be equivalent to a LocalDateTime retrieved from
MySQL because of the truncation of nanoseconds. Use .now() or use the LocalDateTime::of method that
ignores the nanoseconds field
-
Nested Class Summary
Nested classes/interfaces inherited from class io.datarouter.model.field.BaseField
BaseField.FieldColumnNameComparator -
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatterformatterstatic Stringpattern -
Constructor Summary
Constructors Constructor Description LocalDateTimeField(LocalDateTimeFieldKey key, LocalDateTime value)LocalDateTimeField(String prefix, LocalDateTimeFieldKey key, LocalDateTime value) -
Method Summary
Modifier and Type Method Description LocalDateTimefromBytesButDoNotSet(byte[] bytes, int offset)byte[]getBytes()intgetNumFractionalSeconds()StringgetStringEncodedValue()LocalDateTimegetTruncatedLocalDateTime(LocalDateTime value)intnumBytesWithSeparator(byte[] bytes, int offset)LocalDateTimeparseStringEncodedValueButDoNotSet(String str)Methods inherited from class io.datarouter.model.field.BaseField
fromBytesWithSeparatorButDoNotSet, fromString, getBytesWithSeparator, getPrefix, getPrefixedName, getPreparedStatementValue, getValue, getValueHashCode, getValueString, setPrefix, setUsingReflection, setValue, toString
-
Field Details
-
pattern
- See Also:
- Constant Field Values
-
formatter
-
-
Constructor Details
-
Method Details
-
getTruncatedLocalDateTime
-
getNumFractionalSeconds
public int getNumFractionalSeconds() -
getStringEncodedValue
-
parseStringEncodedValueButDoNotSet
-
getBytes
public byte[] getBytes() -
numBytesWithSeparator
public int numBytesWithSeparator(byte[] bytes, int offset) -
fromBytesButDoNotSet
-