Class AbstractDateTimeSerializer<T>

    • Field Detail

      • UTC

        public static final ZoneId UTC
    • Constructor Detail

      • AbstractDateTimeSerializer

        public AbstractDateTimeSerializer​(Customization customization)
        Creates a new instance.
        Parameters:
        customization - Model customization.
    • Method Detail

      • serialize

        public void serialize​(T obj,
                              javax.json.stream.JsonGenerator generator,
                              javax.json.bind.serializer.SerializationContext ctx)
        Description copied from class: AbstractValueTypeSerializer
        Serializes an object to JSON.
        Specified by:
        serialize in interface javax.json.bind.serializer.JsonbSerializer<T>
        Overrides:
        serialize in class AbstractValueTypeSerializer<T>
        Parameters:
        obj - Object to serialize.
        generator - JSON generator to use.
        ctx - JSON-B mapper context.
      • toJson

        public String toJson​(T object,
                             JsonbDateFormatter formatter,
                             JsonbContext jsonbContext)
        Converts to JSON string.
        Parameters:
        object - Object to convert.
        formatter - Formatter to use.
        jsonbContext - JSON-B context.
        Returns:
        JSON representation of given object.
      • getZonedFormatter

        protected DateTimeFormatter getZonedFormatter​(DateTimeFormatter formatter)
        Append UTC zone in case zone is not set on formatter.
        Parameters:
        formatter - formatter
        Returns:
        zoned formatter
      • toInstant

        protected abstract Instant toInstant​(T value)
        Convert java.time object to epoch milliseconds instant. Discards zone offset and zone id information.
        Parameters:
        value - date object to convert
        Returns:
        instant
      • formatDefault

        protected abstract String formatDefault​(T value,
                                                Locale locale)
        Format with default formatter for a given java.time date object. Different default formatter for each date object type is used.
        Parameters:
        value - date object
        locale - locale from annotation / default not null
        Returns:
        formatted date obj as string
      • formatWithFormatter

        protected String formatWithFormatter​(T value,
                                             DateTimeFormatter formatter)
        Format date object with given formatter
        Parameters:
        value - date object to format
        formatter - formatter to format with
        Returns:
        formatted result
      • formatStrictIJson

        protected String formatStrictIJson​(T value)
        Format date object as strict IJson date format.
        Parameters:
        value - value to format
        Returns:
        formatted result