Package: org.apache.groovy.datetime.extensions

## [Java] Class DateTimeStaticExtensions

- org.apache.groovy.datetime.extensions.DateTimeStaticExtensions

-     public class DateTimeStaticExtensions

  This class defines new static extension methods which appear on normal JDK Date/Time API (java.time) classes inside the Groovy environment.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Period` | `between(Period type, Year startInclusive, Year endExclusive)` Obtains a Period consisting of the number of years between two Year instances.
    `` | `public static Period` | `between(Period type, YearMonth startInclusive, YearMonth endExclusive)` Obtains a Period consisting of the number of years and months between two YearMonth instances.
    `` | `public static LocalDate` | `parse(LocalDate type, CharSequence text, String pattern)` Parse text into a LocalDate using the provided pattern.
    `` | `public static LocalDateTime` | `parse(LocalDateTime type, CharSequence text, String pattern)` Parse text into a LocalDateTime using the provided pattern.
    `` | `public static LocalTime` | `parse(LocalTime type, CharSequence text, String pattern)` Parse text into a LocalTime using the provided pattern.
    `` | `public static MonthDay` | `parse(MonthDay type, CharSequence text, String pattern)` Parse text into a MonthDay using the provided pattern.
    `` | `public static OffsetDateTime` | `parse(OffsetDateTime type, CharSequence text, String pattern)` Parse text into an OffsetDateTime using the provided pattern.
    `` | `public static OffsetTime` | `parse(OffsetTime type, CharSequence text, String pattern)` Parse text into an OffsetTime using the provided pattern.
    `` | `public static Year` | `parse(Year type, CharSequence text, String pattern)` Parse text into a Year using the provided pattern.
    `` | `public static YearMonth` | `parse(YearMonth type, CharSequence text, String pattern)` Parse text into a YearMonth using the provided pattern.
    `` | `public static ZonedDateTime` | `parse(ZonedDateTime type, CharSequence text, String pattern)` Parse text into a ZonedDateTime using the provided pattern.
    `` | `public static ZoneOffset` | `systemDefault(ZoneOffset type)` Returns the ZoneOffset currently associated with the system default ZoneId.

  - ### Inherited Methods Summary

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

- - ### Method Detail

    - #### public static Period between(Period type, Year startInclusive, Year endExclusive)

      Obtains a Period consisting of the number of years between two Year instances. The months and days of the Period will be zero. The result of this method can be a negative period if the end is before the start.

      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `startInclusive` - the start Year, inclusive, not null
        `endExclusive` - the end Year, exclusive, not null
      Returns:
        a Period between the years
      See Also:
        Period.between

    - #### public static Period between(Period type, YearMonth startInclusive, YearMonth endExclusive)

      Obtains a Period consisting of the number of years and months between two YearMonth instances. The days of the Period will be zero. The result of this method can be a negative period if the end is before the start.

      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `startInclusive` - the start YearMonth, inclusive, not null
        `endExclusive` - the end YearMonth, exclusive, not null
      Returns:
        a Period between the year/months
      See Also:
        Period.between

    - #### public static LocalDate parse(LocalDate type, CharSequence text, String pattern)

      Parse text into a LocalDate using the provided pattern. Note: the order of parameters differs from versions of this method for the legacy Date class.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a LocalDate representing the parsed text
      See Also:
        DateTimeFormatter
        LocalDate.parse
      Since:
        2.5.0

    - #### public static LocalDateTime parse(LocalDateTime type, CharSequence text, String pattern)

      Parse text into a LocalDateTime using the provided pattern. Note: the order of parameters differs from versions of this method for the legacy Date class.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a LocalDateTime representing the parsed text
      See Also:
        DateTimeFormatter
        LocalDateTime.parse
      Since:
        2.5.0

    - #### public static LocalTime parse(LocalTime type, CharSequence text, String pattern)

      Parse text into a LocalTime using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a LocalTime representing the parsed text
      See Also:
        DateTimeFormatter
        LocalTime.parse
      Since:
        2.5.0

    - #### public static MonthDay parse(MonthDay type, CharSequence text, String pattern)

      Parse text into a MonthDay using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a MonthDay representing the parsed text
      See Also:
        DateTimeFormatter
        MonthDay.parse
      Since:
        2.5.0

    - #### public static OffsetDateTime parse(OffsetDateTime type, CharSequence text, String pattern)

      Parse text into an OffsetDateTime using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        an OffsetDateTime representing the parsed text
      See Also:
        DateTimeFormatter
        OffsetDateTime.parse
      Since:
        2.5.0

    - #### public static OffsetTime parse(OffsetTime type, CharSequence text, String pattern)

      Parse text into an OffsetTime using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        an OffsetTime representing the parsed text
      See Also:
        DateTimeFormatter
        OffsetTime.parse
      Since:
        2.5.0

    - #### public static Year parse(Year type, CharSequence text, String pattern)

      Parse text into a Year using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a Year representing the parsed text
      See Also:
        DateTimeFormatter
        Year.parse
      Since:
        2.5.0

    - #### public static YearMonth parse(YearMonth type, CharSequence text, String pattern)

      Parse text into a YearMonth using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a YearMonth representing the parsed text
      See Also:
        DateTimeFormatter
        YearMonth.parse
      Since:
        2.5.0

    - #### public static ZonedDateTime parse(ZonedDateTime type, CharSequence text, String pattern)

      Parse text into a ZonedDateTime using the provided pattern.

      throws:
        java.lang.IllegalArgumentException if the pattern is invalid
      throws:
        java.time.format.DateTimeParseException if the text cannot be parsed
      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
        `text` - String to be parsed to create the date instance
        `pattern` - pattern used to parse the text
      Returns:
        a ZonedDateTime representing the parsed text
      See Also:
        DateTimeFormatter
        ZonedDateTime.parse
      Since:
        2.5.0

    - #### public static ZoneOffset systemDefault(ZoneOffset type)

      Returns the ZoneOffset currently associated with the system default ZoneId.

      Parameters:
        `type` - placeholder variable used by Groovy categories; ignored for default static methods
      Returns:
        a ZoneOffset
      See Also:
        ZoneId.systemDefault
      Since:
        2.5.0