Package: org.apache.groovy.json.internal

## [Java] Class Dates

- org.apache.groovy.json.internal.Dates

-     public class Dates
      extends Object

  Date helpers used by the JSON parser for supported timestamp formats.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static int` | `JSON_TIME_LENGTH` | Length of a JSON timestamp with millisecond precision.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Date` | `fromISO8601(char[] charArray, int from, int to)` Parses a supported ISO-8601 timestamp without milliseconds.
    `` | `public static Date` | `fromJsonDate(char[] charArray, int from, int to)` Parses a supported JSON timestamp with millisecond precision.
    `` | `public static boolean` | `isISO8601(char[] charArray, int start, int to)` Checks whether a slice matches the parser's supported ISO-8601 layouts.
    `` | `public static boolean` | `isISO8601QuickCheck(char[] charArray, int start, int to)` Performs a quick length and separator check for ISO-8601-like values.
    `` | `public static boolean` | `isJsonDate(char[] charArray, int start, int to)` Checks whether a slice matches the parser's JSON date layout.
    `` | `public static Date` | `toDate(TimeZone tz, int year, int month, int day, int hour, int minute, int second)` Creates a Date from date-time fields in the supplied time zone.
    `` | `public static Date` | `toDate(TimeZone tz, int year, int month, int day, int hour, int minute, int second, int milliseconds)` Creates a Date from date-time fields including milliseconds.
    `` | `public static long` | `utc(long time)` Returns the epoch milliseconds for the supplied instant using a UTC-based calendar.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final int JSON_TIME_LENGTH

      Length of a JSON timestamp with millisecond precision.

  - ### Method Detail

    - #### public static Date fromISO8601(char[] charArray, int from, int to)

      Parses a supported ISO-8601 timestamp without milliseconds.

      Parameters:
        `charArray` - source character buffer
        `from` - inclusive start index
        `to` - exclusive end index
      Returns:
        parsed date, or `null` when the slice is not a supported ISO-8601 value

    - #### public static Date fromJsonDate(char[] charArray, int from, int to)

      Parses a supported JSON timestamp with millisecond precision.

      Parameters:
        `charArray` - source character buffer
        `from` - inclusive start index
        `to` - exclusive end index
      Returns:
        parsed date, or `null` when the slice is not a supported JSON date value

    - #### public static boolean isISO8601(char[] charArray, int start, int to)

      Checks whether a slice matches the parser's supported ISO-8601 layouts.

      Parameters:
        `charArray` - source character buffer
        `start` - inclusive start index
        `to` - exclusive end index
      Returns:
        `true` when the slice matches a supported ISO-8601 layout

    - #### public static boolean isISO8601QuickCheck(char[] charArray, int start, int to)

      Performs a quick length and separator check for ISO-8601-like values.

      Parameters:
        `charArray` - source character buffer
        `start` - inclusive start index
        `to` - exclusive end index
      Returns:
        `true` when the slice looks like an ISO-8601 value

    - #### public static boolean isJsonDate(char[] charArray, int start, int to)

      Checks whether a slice matches the parser's JSON date layout.

      Parameters:
        `charArray` - source character buffer
        `start` - inclusive start index
        `to` - exclusive end index
      Returns:
        `true` when the slice matches the JSON date layout

    - #### public static Date toDate(TimeZone tz, int year, int month, int day, int hour, int minute, int second)

      Creates a Date from date-time fields in the supplied time zone.

      Parameters:
        `tz` - time zone to apply
        `year` - year value
        `month` - month value from `1` to `12`
        `day` - day of month
        `hour` - hour of day
        `minute` - minute of hour
        `second` - second of minute
      Returns:
        created date

    - #### public static Date toDate(TimeZone tz, int year, int month, int day, int hour, int minute, int second, int milliseconds)

      Creates a Date from date-time fields including milliseconds.

      Parameters:
        `tz` - time zone to apply
        `year` - year value
        `month` - month value from `1` to `12`
        `day` - day of month
        `hour` - hour of day
        `minute` - minute of hour
        `second` - second of minute
        `milliseconds` - millisecond value
      Returns:
        created date

    - #### public static long utc(long time)

      Returns the epoch milliseconds for the supplied instant using a UTC-based calendar.

      Parameters:
        `time` - epoch milliseconds
      Returns:
        UTC-normalized epoch milliseconds