public class DateTimeStaticExtensions extends Object
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 . |
public static LocalDate parse(LocalDate type, CharSequence text, String pattern)
LocalDate
using the provided pattern.
Note: the order of parameters differs from versions of this method for the legacy Date class.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
LocalDate.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static LocalDateTime parse(LocalDateTime type, CharSequence text, String pattern)
LocalDateTime
using the provided pattern.
Note: the order of parameters differs from versions of this method for the legacy Date class.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
LocalDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static LocalTime parse(LocalTime type, CharSequence text, String pattern)
LocalTime
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
LocalTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static MonthDay parse(MonthDay type, CharSequence text, String pattern)
MonthDay
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
MonthDay.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static OffsetDateTime parse(OffsetDateTime type, CharSequence text, String pattern)
OffsetDateTime
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
OffsetDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static OffsetTime parse(OffsetTime type, CharSequence text, String pattern)
OffsetTime
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
OffsetTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static Year parse(Year type, CharSequence text, String pattern)
Year
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
Year.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static YearMonth parse(YearMonth type, CharSequence text, String pattern)
YearMonth
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
YearMonth.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static ZonedDateTime parse(ZonedDateTime type, CharSequence text, String pattern)
ZonedDateTime
using the provided pattern.type
- placeholder variable used by Groovy categories; ignored for default static methodstext
- String to be parsed to create the date instancepattern
- pattern used to parse the textIllegalArgumentException
- if the pattern is invalidDateTimeParseException
- if the text cannot be parsedDateTimeFormatter
,
ZonedDateTime.parse(java.lang.CharSequence, java.time.format.DateTimeFormatter)
public static ZoneOffset systemDefault(ZoneOffset type)
ZoneOffset
currently associated with the system default ZoneId
.type
- placeholder variable used by Groovy categories; ignored for default static methodsZoneId.systemDefault()
public static Period between(Period type, Year startInclusive, Year endExclusive)
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.type
- placeholder variable used by Groovy categories; ignored for default static methodsstartInclusive
- the start Year
, inclusive, not nullendExclusive
- the end Year
, exclusive, not nullPeriod.between(LocalDate, LocalDate)
public static Period between(Period type, YearMonth startInclusive, YearMonth endExclusive)
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.type
- placeholder variable used by Groovy categories; ignored for default static methodsstartInclusive
- the start YearMonth
, inclusive, not nullendExclusive
- the end YearMonth
, exclusive, not nullPeriod.between(LocalDate, LocalDate)