Class DatetimeConverter
java.lang.Object
org.incenp.linkml.core.ScalarConverterBase
org.incenp.linkml.core.DatetimeConverter
- All Implemented Interfaces:
IConverter
A converter for slots typed as
xsd:datetime (represented as
ZonedDateTime).
This supports LinkML’s datetime type. Unfortunately, the LinkML
specification says nothing about how a datetime value is expected to be
serialised, so the behaviour of this converter is based on the behaviour of
the LinkML-Py implementation.
When deserialising, this converter expects a ISO8601-like string, where the
separator between the date and time parts can be either 'T' or a
space. Also, it accepts a string containing the date part only.
When serialising, the converter turns a ZonedDateTime object into a
ISO8601-like string with 'T' as the date/time separator.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectconvertImpl(Object raw, ConverterContext ctx) Performs the actual type conversion.Class<?> getType()Gets the type of object that this converter can convert a raw object into.serialise(Object object, ConverterContext ctx) Converts a LinkML object into a raw object.Methods inherited from class ScalarConverterBase
convert, convertForSlot, serialiseForSlot, toList
-
Constructor Details
-
DatetimeConverter
public DatetimeConverter()
-
-
Method Details
-
getType
Description copied from interface:IConverterGets the type of object that this converter can convert a raw object into.- Returns:
- The Java type representing the LinkML object this converter is intended for.
-
convertImpl
Description copied from class:ScalarConverterBasePerforms the actual type conversion.- Specified by:
convertImplin classScalarConverterBase- Parameters:
raw- The raw object to convert. This is guaranteed to be a non-null, non-list, non-dictionary object.- Returns:
- The converted value.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value.
-
serialise
Description copied from interface:IConverterConverts a LinkML object into a raw object.Given the Java representation of a LinkML object, this method shall return an object suitable to be given to a generic JSON/YAML writer.
- Specified by:
serialisein interfaceIConverter- Overrides:
serialisein classScalarConverterBase- Parameters:
object- The LinkML object to convert.ctx- The global converter context.- Returns:
- The raw object that represents the original LinkML object.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given object.
-