Class DateTimeStaticExtensions
java.lang.Object
org.apache.groovy.datetime.extensions.DateTimeStaticExtensions
This class defines new static extension methods which appear on normal JDK
 Date/Time API (java.time) classes inside the Groovy environment.
- 
Method SummaryModifier and TypeMethodDescriptionstatic PeriodObtains a Period consisting of the number of years and months between twoYearMonthinstances.static PeriodObtains a Period consisting of the number of years between twoYearinstances.static LocalDateparse(LocalDate type, CharSequence text, String pattern) Parse text into aLocalDateusing the provided pattern.static LocalDateTimeparse(LocalDateTime type, CharSequence text, String pattern) Parse text into aLocalDateTimeusing the provided pattern.static LocalTimeparse(LocalTime type, CharSequence text, String pattern) Parse text into aLocalTimeusing the provided pattern.static MonthDayparse(MonthDay type, CharSequence text, String pattern) Parse text into aMonthDayusing the provided pattern.static OffsetDateTimeparse(OffsetDateTime type, CharSequence text, String pattern) Parse text into anOffsetDateTimeusing the provided pattern.static OffsetTimeparse(OffsetTime type, CharSequence text, String pattern) Parse text into anOffsetTimeusing the provided pattern.static YearMonthparse(YearMonth type, CharSequence text, String pattern) Parse text into aYearMonthusing the provided pattern.static Yearparse(Year type, CharSequence text, String pattern) Parse text into aYearusing the provided pattern.static ZonedDateTimeparse(ZonedDateTime type, CharSequence text, String pattern) Parse text into aZonedDateTimeusing the provided pattern.static ZoneOffsetsystemDefault(ZoneOffset type) Returns theZoneOffsetcurrently associated with the system defaultZoneId.
- 
Method Details- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
parseParse 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:
- IllegalArgumentException- if the pattern is invalid
- DateTimeParseException- if the text cannot be parsed
- Since:
- 2.5.0
- See Also:
 
- 
systemDefaultReturns 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:
 
- 
betweenObtains 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.
- 
betweenObtains 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.
 
-