Class DateTimeStaticExtensions
- java.lang.Object
- 
- org.apache.groovy.datetime.extensions.DateTimeStaticExtensions
 
- 
 public class DateTimeStaticExtensions extends java.lang.ObjectThis class defines new static extension methods which appear on normal JDK Date/Time API (java.time) classes inside the Groovy environment.
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.time.Periodbetween(java.time.Period type, java.time.YearMonth startInclusive, java.time.YearMonth endExclusive)Obtains a Period consisting of the number of years and months between twoYearMonthinstances.static java.time.Periodbetween(java.time.Period type, java.time.Year startInclusive, java.time.Year endExclusive)Obtains a Period consisting of the number of years between twoYearinstances.static java.time.LocalDateparse(java.time.LocalDate type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aLocalDateusing the provided pattern.static java.time.LocalDateTimeparse(java.time.LocalDateTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aLocalDateTimeusing the provided pattern.static java.time.LocalTimeparse(java.time.LocalTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aLocalTimeusing the provided pattern.static java.time.MonthDayparse(java.time.MonthDay type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aMonthDayusing the provided pattern.static java.time.OffsetDateTimeparse(java.time.OffsetDateTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into anOffsetDateTimeusing the provided pattern.static java.time.OffsetTimeparse(java.time.OffsetTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into anOffsetTimeusing the provided pattern.static java.time.YearMonthparse(java.time.YearMonth type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aYearMonthusing the provided pattern.static java.time.Yearparse(java.time.Year type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aYearusing the provided pattern.static java.time.ZonedDateTimeparse(java.time.ZonedDateTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aZonedDateTimeusing the provided pattern.static java.time.ZoneOffsetsystemDefault(java.time.ZoneOffset type)Returns theZoneOffsetcurrently associated with the system defaultZoneId.
 
- 
- 
- 
Method Detail- 
parsepublic static java.time.LocalDate parse(java.time.LocalDate type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aLocalDateusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- LocalDate.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.LocalDateTime parse(java.time.LocalDateTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aLocalDateTimeusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- LocalDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.LocalTime parse(java.time.LocalTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aLocalTimeusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- LocalTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.MonthDay parse(java.time.MonthDay type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aMonthDayusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- MonthDay.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.OffsetDateTime parse(java.time.OffsetDateTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into anOffsetDateTimeusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- OffsetDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.OffsetTime parse(java.time.OffsetTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into anOffsetTimeusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- OffsetTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.Year parse(java.time.Year type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aYearusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- Year.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.YearMonth parse(java.time.YearMonth type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aYearMonthusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- YearMonth.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
parsepublic static java.time.ZonedDateTime parse(java.time.ZonedDateTime type, java.lang.CharSequence text, java.lang.String pattern)Parse text into aZonedDateTimeusing 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:
- java.lang.IllegalArgumentException- if the pattern is invalid
- java.time.format.DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
- DateTimeFormatter,- ZonedDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
 
 - 
systemDefaultpublic static java.time.ZoneOffset systemDefault(java.time.ZoneOffset type) Returns theZoneOffsetcurrently associated with the system defaultZoneId.- Parameters:
- type- placeholder variable used by Groovy categories; ignored for default static methods
- Returns:
- a ZoneOffset
- Since:
- 2.5.0
- See Also:
- ZoneId.systemDefault()
 
 - 
betweenpublic static java.time.Period between(java.time.Period type, java.time.Year startInclusive, java.time.Year endExclusive)Obtains a Period consisting of the number of years between twoYearinstances. 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)
 
 - 
betweenpublic static java.time.Period between(java.time.Period type, java.time.YearMonth startInclusive, java.time.YearMonth endExclusive)Obtains a Period consisting of the number of years and months between twoYearMonthinstances. 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)
 
 
- 
 
-