Class JSONDateFormatConverter

java.lang.Object
com.blackrook.json.converters.JSONDateFormatConverter
All Implemented Interfaces:
JSONConverter<Date>
Direct Known Subclasses:
JSONISODateTimeConverter

public class JSONDateFormatConverter extends Object implements JSONConverter<Date>
A special converter that converts dates from strings to Dates in JSON member data.
Since:
1.3.0
Author:
Matthew Tropiano
  • Constructor Details

    • JSONDateFormatConverter

      public JSONDateFormatConverter(String format)
      Creates a new converter using a SimpleDateFormat string.
      Parameters:
      format - the format string.
    • JSONDateFormatConverter

      public JSONDateFormatConverter(String format, TimeZone timeZone)
      Creates a new converter using a SimpleDateFormat string.
      Parameters:
      format - the format string.
      timeZone - the date's target timezone before conversion.
  • Method Details

    • getJSONObject

      public JSONObject getJSONObject(Date object)
      Description copied from interface: JSONConverter
      Returns a JSON object that represents this object instance (and its contents). The policy of this method is to help return something that can be converted back to Java via JSONConverter.getObject(JSONObject) with close-to or dead-on 100% equivalence.
      Specified by:
      getJSONObject in interface JSONConverter<Date>
      Parameters:
      object - the object to inspect.
      Returns:
      an accurate JSONObject that represents this object.
    • getObject

      public Date getObject(JSONObject jsonObject)
      Description copied from interface: JSONConverter
      Returns a Java Object that is equivalent to the input JSON Object.
      Specified by:
      getObject in interface JSONConverter<Date>
      Parameters:
      jsonObject - the JSON Object to convert.
      Returns:
      an accurate object from the JSON.