org.apache.groovy.datetime.extensions

## Class DateTimeStaticExtensions

- java.lang.Object
- - org.apache.groovy.datetime.extensions.DateTimeStaticExtensions

-     public class DateTimeStaticExtensions
      extends Object

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

- - ### Method Summary

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

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### parse

          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.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `LocalDate.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

          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.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `LocalDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into a `LocalTime` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `LocalTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into a `MonthDay` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `MonthDay.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into an `OffsetDateTime` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `OffsetDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into an `OffsetTime` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `OffsetTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into a `Year` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `Year.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into a `YearMonth` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `YearMonth.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### parse

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

      Parse text into a `ZonedDateTime` using the provided pattern.
      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
      Throws:
        `IllegalArgumentException` - if the pattern is invalid
        `DateTimeParseException` - if the text cannot be parsed
      Since:
        2.5.0
      See Also:
        `DateTimeFormatter`, `ZonedDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)`

    - #### systemDefault

          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
      Since:
        2.5.0
      See Also:
        `ZoneId.systemDefault()`

    - #### between

          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(LocalDate, LocalDate)`

    - #### 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(LocalDate, LocalDate)`