Package groovy.json

Enum Class JsonDateHandling

java.lang.Object
java.lang.Enum<JsonDateHandling>
groovy.json.JsonDateHandling
All Implemented Interfaces:
Serializable, Comparable<JsonDateHandling>, Constable

public enum JsonDateHandling extends Enum<JsonDateHandling>
What a slurper makes of a string in a full ISO-8601 or JSON-date form.

This applies to JsonParserType.INDEX_OVERLAY and JsonParserType.LAX. The other two parser types have no date handling and return the string whatever is chosen here. A date carrying no time, such as "2026-09-04", is left as a String by every parser type.

Since:
6.0.0
  • Enum Constant Details

    • STRING

      public static final JsonDateHandling STRING
      Leave it as a String, as it appears in the document.
    • UTIL_DATE

      public static final JsonDateHandling UTIL_DATE
      Convert to a Date. This is the default, and what a slurper has always done. A Date is an instant, so an offset in the source is not preserved.
    • INSTANT

      public static final JsonDateHandling INSTANT
      Convert to a Instant, which like Date is a point on the timeline and so does not preserve an offset in the source.
    • OFFSET_DATE_TIME

      public static final JsonDateHandling OFFSET_DATE_TIME
      Convert to a OffsetDateTime, the only choice here that keeps the offset the document carried.
  • Method Details

    • values

      public static JsonDateHandling[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JsonDateHandling valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null