Class TemporalPropertySerializer

java.lang.Object
net.solarnetwork.codec.TemporalPropertySerializer
All Implemented Interfaces:
PropertySerializer

public class TemporalPropertySerializer extends Object implements PropertySerializer
Property serializer for dates and times.
Since:
2.0
Version:
1.0
Author:
matt
  • Constructor Details

    • TemporalPropertySerializer

      public TemporalPropertySerializer(String pattern)
      Constructor.

      The UTC time zone will be used.

      Parameters:
      pattern - the pattern to use
    • TemporalPropertySerializer

      public TemporalPropertySerializer(String pattern, ZoneId zone)
      Constructor.
      Parameters:
      pattern - the pattern to use
      zone - if not null then a zone to use
    • TemporalPropertySerializer

      public TemporalPropertySerializer(DateTimeFormatter formatter)
      Constructor.
      Parameters:
      formatter - the formatter to use
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • serialize

      public Object serialize(Object data, String propertyName, Object propertyValue)
      Description copied from interface: PropertySerializer
      Serialize a property value.

      The data and propertyName parameters might not be used by different implementations, but allow for a single implementation to serialize more than one property of an object in different ways, if desired.

      Specified by:
      serialize in interface PropertySerializer
      Parameters:
      data - the source data being serialized, i.e. a JavaBean
      propertyName - the name of the property being serialized
      propertyValue - the value of the property to serialize
      Returns:
      the serialized value of the property