public class DateTimeExtensions
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.time.LocalDateTime |
clearTime(java.time.LocalDateTime self)
Returns a
LocalDateTime with the time portion cleared. |
static java.time.OffsetDateTime |
clearTime(java.time.OffsetDateTime self)
Returns an
OffsetDateTime with the time portion cleared. |
static java.time.ZonedDateTime |
clearTime(java.time.ZonedDateTime self)
Returns an
ZonedDateTime with the time portion cleared. |
static java.time.Duration |
div(java.time.Duration self,
long scalar)
Supports the division operator; equivalent to calling the
Duration.dividedBy(long) method. |
static void |
downto(java.time.temporal.Temporal from,
java.time.temporal.Temporal to,
Closure closure)
Iterates from this to the
to Temporal , inclusive, decrementing by one
unit each iteration, calling the closure once per iteration. |
static void |
downto(java.time.temporal.Temporal from,
java.time.temporal.Temporal to,
java.time.temporal.TemporalUnit unit,
Closure closure)
Iterates from this to the
to Temporal , inclusive, decrementing by one
unit each iteration, calling the closure once per iteration. |
static java.lang.String |
format(java.time.LocalDate self,
java.time.format.FormatStyle dateStyle)
Formats this date in the provided, localized
FormatStyle . |
static java.lang.String |
format(java.time.LocalDate self,
java.lang.String pattern)
Formats this date with the provided
DateTimeFormatter pattern. |
static java.lang.String |
format(java.time.LocalDateTime self,
java.time.format.FormatStyle dateTimeStyle)
Formats this date/time in the provided, localized
FormatStyle . |
static java.lang.String |
format(java.time.LocalDateTime self,
java.lang.String pattern)
Formats this date/time with the provided
DateTimeFormatter pattern. |
static java.lang.String |
format(java.time.LocalTime self,
java.time.format.FormatStyle timeStyle)
Formats this time in the provided, localized
FormatStyle . |
static java.lang.String |
format(java.time.LocalTime self,
java.lang.String pattern)
Formats this time with the provided
DateTimeFormatter pattern. |
static java.lang.String |
format(java.time.OffsetDateTime self,
java.time.format.FormatStyle dateTimeStyle)
Formats this date/time in the provided, localized
FormatStyle . |
static java.lang.String |
format(java.time.OffsetDateTime self,
java.lang.String pattern)
Formats this date/time with the provided
DateTimeFormatter pattern. |
static java.lang.String |
format(java.time.OffsetTime self,
java.time.format.FormatStyle timeStyle)
Formats this time in the provided, localized
FormatStyle . |
static java.lang.String |
format(java.time.OffsetTime self,
java.lang.String pattern)
Formats this time with the provided
DateTimeFormatter pattern. |
static java.lang.String |
format(java.time.ZonedDateTime self,
java.time.format.FormatStyle dateTimeStyle)
Formats this date/time in the provided, localized
FormatStyle . |
static java.lang.String |
format(java.time.ZonedDateTime self,
java.lang.String pattern)
Formats this date/time with the provided
DateTimeFormatter pattern. |
static long |
getAt(java.time.temporal.TemporalAccessor self,
java.time.temporal.TemporalField field)
Supports the getAt operator; equivalent to calling the
TemporalAccessor.getLong(java.time.temporal.TemporalField) method. |
static long |
getAt(java.time.temporal.TemporalAmount self,
java.time.temporal.TemporalUnit unit)
Supports the getAt operator; equivalent to calling the
TemporalAmount.get(TemporalUnit) method. |
static long |
getAt(java.time.ZoneOffset self,
java.time.temporal.TemporalField field)
Supports the getAt operator; equivalent to calling the
ZoneOffset.getLong(java.time.temporal.TemporalField) method. |
static java.lang.String |
getDateString(java.time.LocalDate self)
Formats this date with the
DateTimeFormatter.ISO_LOCAL_DATE formatter. |
static java.lang.String |
getDateString(java.time.LocalDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_LOCAL_DATE formatter. |
static java.lang.String |
getDateString(java.time.OffsetDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_OFFSET_DATE formatter. |
static java.lang.String |
getDateString(java.time.ZonedDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_LOCAL_DATE formatter
and appends the zone's short name, e.g. |
static java.lang.String |
getDateTimeString(java.time.LocalDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_LOCAL_DATE_TIME formatter. |
static java.lang.String |
getDateTimeString(java.time.OffsetDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_OFFSET_DATE_TIME formatter. |
static java.lang.String |
getDateTimeString(java.time.ZonedDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_LOCAL_DATE_TIME formatter
and appends the zone's short name, e.g. |
static int |
getEra(java.time.Year self)
Equivalent to calling the
Year.get(java.time.temporal.TemporalField) method with a
ChronoField.ERA argument. |
static java.lang.String |
getFullName(java.time.ZoneId self)
Returns the name of this zone formatted according to the
TextStyle.FULL text style. |
static java.lang.String |
getFullName(java.time.ZoneId self,
java.util.Locale locale)
Returns the name of this zone formatted according to the
TextStyle.FULL text style
for the provided Locale . |
static int |
getHours(java.time.ZoneOffset self)
Returns the hours component of this offset.
|
static int |
getMinutes(java.time.ZoneOffset self)
Returns the minutes component of this offset.
|
static java.time.ZoneOffset |
getOffset(java.time.ZoneId self)
Returns a
ZoneOffset for this zone as of now. |
static java.time.ZoneOffset |
getOffset(java.time.ZoneId self,
java.time.Instant instant)
Returns a
ZoneOffset for this zone as of the provided Instant . |
static int |
getSeconds(java.time.ZoneOffset self)
Returns the seconds component of this offset.
|
static java.lang.String |
getShortName(java.time.ZoneId self)
Returns the name of this zone formatted according to the
TextStyle.SHORT text style. |
static java.lang.String |
getShortName(java.time.ZoneId self,
java.util.Locale locale)
Returns the name of this zone formatted according to the
TextStyle.SHORT text style
for the provided Locale . |
static java.lang.String |
getTimeString(java.time.LocalDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_LOCAL_TIME formatter. |
static java.lang.String |
getTimeString(java.time.LocalTime self)
Formats this time with the
DateTimeFormatter.ISO_LOCAL_TIME formatter. |
static java.lang.String |
getTimeString(java.time.OffsetDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_OFFSET_TIME formatter. |
static java.lang.String |
getTimeString(java.time.OffsetTime self)
Formats this time with the
DateTimeFormatter.ISO_OFFSET_TIME formatter. |
static java.lang.String |
getTimeString(java.time.ZonedDateTime self)
Formats this date/time with the
DateTimeFormatter.ISO_LOCAL_TIME formatter
and appends the zone's short name, e.g. |
static int |
getYearOfEra(java.time.Year self)
Equivalent to calling the
Year.get(java.time.temporal.TemporalField) method with a
ChronoField.YEAR_OF_ERA argument. |
static java.time.ZoneId |
getZoneId(java.util.Calendar self)
Returns the Time Zone of the Calendar as a java.time.ZoneId.
|
static java.time.ZoneId |
getZoneId(java.util.Date self)
Returns the Time Zone of the Date as a
ZoneId . |
static java.time.ZoneOffset |
getZoneOffset(java.util.Calendar self)
Returns the Time Zone offset of the Calendar as a
ZoneOffset . |
static java.time.ZoneOffset |
getZoneOffset(java.util.Date self)
Returns the Time Zone offset of the Date as a
ZoneOffset ,
which will typically be system's default offset. |
static boolean |
isNonnegative(java.time.chrono.ChronoPeriod self)
Returns true if this period is zero or positive.
|
static boolean |
isNonnegative(java.time.Duration self)
Returns true if this duration is zero or positive.
|
static boolean |
isNonpositive(java.time.chrono.ChronoPeriod self)
Returns true if this period is zero or negative.
|
static boolean |
isNonpositive(java.time.Duration self)
Returns true if this duration is zero or negative.
|
static boolean |
isPositive(java.time.chrono.ChronoPeriod self)
Returns true if this period is positive, excluding zero.
|
static boolean |
isPositive(java.time.Duration self)
Returns true if this duration is positive, excluding zero.
|
static boolean |
isWeekday(java.time.DayOfWeek self)
Returns
true if the DayOfWeek is a weekday. |
static boolean |
isWeekend(java.time.DayOfWeek self)
Returns
true if this day of the week is a weekend day (Saturday or Sunday). |
static java.time.LocalDateTime |
leftShift(java.time.LocalDate self,
java.time.LocalTime time)
Returns a
LocalDateTime from this date and the provided LocalTime . |
static java.time.OffsetDateTime |
leftShift(java.time.LocalDate self,
java.time.OffsetTime time)
Returns a
OffsetDateTime from this date and the provided OffsetTime . |
static java.time.ZonedDateTime |
leftShift(java.time.LocalDateTime self,
java.time.ZoneId zone)
Returns a
OffsetDateTime of this date/time and the provided ZoneId . |
static java.time.OffsetDateTime |
leftShift(java.time.LocalDateTime self,
java.time.ZoneOffset offset)
Returns an
OffsetDateTime of this date/time and the provided ZoneOffset . |
static java.time.LocalDateTime |
leftShift(java.time.LocalTime self,
java.time.LocalDate date)
Returns a
LocalDateTime of this time and the provided LocalDate . |
static java.time.OffsetTime |
leftShift(java.time.LocalTime self,
java.time.ZoneOffset offset)
Returns an
OffsetTime of this time and the provided ZoneOffset . |
static java.time.LocalDate |
leftShift(java.time.MonthDay self,
int year)
Returns a
LocalDate of this month/day and the provided year. |
static java.time.LocalDate |
leftShift(java.time.MonthDay self,
java.time.Year year)
Returns a
LocalDate of this month/day and the provided Year . |
static java.time.MonthDay |
leftShift(java.time.Month self,
int dayOfMonth)
Creates a
MonthDay at the provided day of the month. |
static java.time.YearMonth |
leftShift(java.time.Month self,
java.time.Year year)
Creates a
YearMonth at the provided Year . |
static java.time.OffsetDateTime |
leftShift(java.time.OffsetTime self,
java.time.LocalDate date)
Returns an
OffsetDateTime of this time and the provided LocalDate . |
static java.time.YearMonth |
leftShift(java.time.Year self,
java.time.Month month)
Returns a
YearMonth of this year and the provided Month . |
static java.time.LocalDate |
leftShift(java.time.Year self,
java.time.MonthDay monthDay)
Returns a
LocalDate of this year on the given MonthDay . |
static java.time.LocalDate |
leftShift(java.time.YearMonth self,
int dayOfMonth)
Returns a
LocalDate of this year/month and the given day of the month. |
static java.time.ZonedDateTime |
leftShift(java.time.ZoneId self,
java.time.LocalDateTime dateTime)
Returns a
ZonedDateTime of this zone and the given LocalDateTime . |
static java.time.OffsetDateTime |
leftShift(java.time.ZoneOffset self,
java.time.LocalDateTime dateTime)
Returns an
OffsetDateTime of this offset and the provided LocalDateTime . |
static java.time.OffsetTime |
leftShift(java.time.ZoneOffset self,
java.time.LocalTime time)
Returns an
OffsetDateTime of this offset and the provided LocalTime . |
static java.time.DayOfWeek |
minus(java.time.DayOfWeek self,
int days)
Returns the
DayOfWeek that is days many days before this day of the week. |
static java.time.Duration |
minus(java.time.Duration self,
long seconds)
Returns a
Duration that is seconds seconds shorter that this duration. |
static java.time.Instant |
minus(java.time.Instant self,
long seconds)
Returns an
Instant that is seconds seconds before this instant. |
static java.time.LocalDate |
minus(java.time.LocalDate self,
long days)
Returns a
LocalDate that is days days before this date. |
static java.time.LocalDateTime |
minus(java.time.LocalDateTime self,
long seconds)
Returns a
LocalDateTime that is seconds seconds before this date/time. |
static java.time.LocalTime |
minus(java.time.LocalTime self,
long seconds)
Returns a
LocalTime that is seconds seconds before this time. |
static java.time.Month |
minus(java.time.Month self,
int months)
Returns the
Month that is months months before this month. |
static java.time.OffsetDateTime |
minus(java.time.OffsetDateTime self,
long seconds)
Returns an
OffsetDateTime that is seconds seconds before this date/time. |
static java.time.OffsetTime |
minus(java.time.OffsetTime self,
long seconds)
Returns an
OffsetTime that is seconds seconds before this time. |
static java.time.Period |
minus(java.time.Period self,
long days)
Returns a
Period that is days days shorter than this period. |
static java.time.Year |
minus(java.time.Year self,
long years)
Returns a
Year that is years years before this year. |
static java.time.YearMonth |
minus(java.time.YearMonth self,
long months)
Returns a
YearMonth that is months months before this year/month. |
static java.time.ZonedDateTime |
minus(java.time.ZonedDateTime self,
long seconds)
Returns a
ZonedDateTime that is seconds seconds before this date/time. |
static java.time.Duration |
multiply(java.time.Duration self,
long scalar)
Supports the multiplication operator; equivalent to calling the
Duration.multipliedBy(long) method. |
static java.time.Period |
multiply(java.time.Period self,
int scalar)
Supports the multiply operator; equivalent to calling the
Period.multipliedBy(int) method. |
static java.time.Duration |
negative(java.time.Duration self)
Supports the unary minus operator; equivalent to calling the
Duration.negated() method. |
static java.time.Period |
negative(java.time.Period self)
Supports the unary minus operator; equivalent to calling the
Period.negated() method. |
static java.time.Duration |
next(java.time.Duration self)
Returns a
Duration that is one second longer than this duration. |
static java.time.Instant |
next(java.time.Instant self)
Returns an
Instant that is one second after this instant. |
static java.time.LocalDate |
next(java.time.LocalDate self)
Returns a
LocalDate one day after this date. |
static java.time.LocalDateTime |
next(java.time.LocalDateTime self)
Returns a
LocalDateTime that is one second after this date/time. |
static java.time.LocalTime |
next(java.time.LocalTime self)
Returns a
LocalTime that is one second after this time. |
static java.time.OffsetDateTime |
next(java.time.OffsetDateTime self)
Returns an
OffsetDateTime one second after this date/time. |
static java.time.OffsetTime |
next(java.time.OffsetTime self)
Returns an
OffsetTime that is one second after this time. |
static java.time.Period |
next(java.time.Period self)
Returns a
Period that is one day longer than this period. |
static java.time.Year |
next(java.time.Year self)
Returns a
Year after this year. |
static java.time.YearMonth |
next(java.time.YearMonth self)
Returns a
YearMonth that is the month after this year/month. |
static java.time.ZonedDateTime |
next(java.time.ZonedDateTime self)
Returns a
ZonedDateTime that is one second after this date/time. |
static java.time.DayOfWeek |
plus(java.time.DayOfWeek self,
int days)
Returns the
DayOfWeek that is days many days after this day of the week. |
static java.time.Duration |
plus(java.time.Duration self,
long seconds)
Returns a
Duration that is seconds seconds longer than this duration. |
static java.time.Instant |
plus(java.time.Instant self,
long seconds)
Returns an
Instant that is seconds seconds after this instant. |
static java.time.LocalDate |
plus(java.time.LocalDate self,
long days)
Returns a
LocalDate that is days days after this date. |
static java.time.LocalDateTime |
plus(java.time.LocalDateTime self,
long seconds)
Returns a
LocalDateTime that is seconds seconds after this date/time. |
static java.time.LocalTime |
plus(java.time.LocalTime self,
long seconds)
Returns a
LocalTime that is seconds seconds after this time. |
static java.time.Month |
plus(java.time.Month self,
int months)
Returns the
Month that is months months after this month. |
static java.time.OffsetDateTime |
plus(java.time.OffsetDateTime self,
long seconds)
Returns an
OffsetDateTime that is seconds seconds after this date/time. |
static java.time.OffsetTime |
plus(java.time.OffsetTime self,
long seconds)
Returns an
OffsetTime that is seconds seconds after this time. |
static java.time.Period |
plus(java.time.Period self,
long days)
Returns a
Period that is days days longer than this period. |
static java.time.Year |
plus(java.time.Year self,
long years)
Returns a
Year that is years years after this year. |
static java.time.YearMonth |
plus(java.time.YearMonth self,
long months)
Returns a
YearMonth that is months months after this year/month. |
static java.time.ZonedDateTime |
plus(java.time.ZonedDateTime self,
long seconds)
Returns a
ZonedDateTime that is seconds seconds after this date/time. |
static java.time.Duration |
positive(java.time.Duration self)
Supports the unary plus operator; equivalent to calling the
Duration.abs() method. |
static java.time.Period |
positive(java.time.Period self)
Supports the unary plus operator; returns a
Period with all unit values positive. |
static java.time.Duration |
previous(java.time.Duration self)
Returns a
Duration that is one second shorter than this duration. |
static java.time.Instant |
previous(java.time.Instant self)
Returns an
Instant that one second before this instant. |
static java.time.LocalDate |
previous(java.time.LocalDate self)
Returns a
LocalDate one day before this date. |
static java.time.LocalDateTime |
previous(java.time.LocalDateTime self)
Returns a
LocalDateTime that is one second before this date/time. |
static java.time.LocalTime |
previous(java.time.LocalTime self)
Returns a
LocalTime that is one second before this time. |
static java.time.OffsetDateTime |
previous(java.time.OffsetDateTime self)
Returns an
OffsetDateTime one second before this date/time. |
static java.time.OffsetTime |
previous(java.time.OffsetTime self)
Returns an
OffsetTime that is one second before this time. |
static java.time.Period |
previous(java.time.Period self)
Returns a
Period that is one day shorter than this period. |
static java.time.Year |
previous(java.time.Year self)
Returns a
Year before this year. |
static java.time.YearMonth |
previous(java.time.YearMonth self)
Returns a
YearMonth that is the month before this year/month. |
static java.time.ZonedDateTime |
previous(java.time.ZonedDateTime self)
Returns a
ZonedDateTime that is one second before this date/time. |
static java.time.Period |
rightShift(java.time.LocalDate self,
java.time.LocalDate other)
Returns a
Period equivalent to the time between this date (inclusive)
and the provided LocalDate (exclusive). |
static java.time.temporal.TemporalAmount |
rightShift(java.time.temporal.Temporal self,
java.time.temporal.Temporal other)
Returns a
Duration or Period between this (inclusive) and the other
Temporal (exclusive). |
static java.time.Period |
rightShift(java.time.YearMonth self,
java.time.YearMonth other)
Returns a
Period of time between the first day of this year/month (inclusive) and the
given YearMonth (exclusive). |
static java.time.Period |
rightShift(java.time.Year self,
java.time.Year year)
Returns a
Period between the first day of this year (inclusive) and the first day of the
provided Year (exclusive). |
static java.util.Calendar |
toCalendar(java.time.Instant self)
Returns a generally equivalent
Calendar in the GMT time zone, truncated to milliseconds. |
static java.util.Calendar |
toCalendar(java.time.LocalDate self)
Returns an equivalent instance of
Calendar . |
static java.util.Calendar |
toCalendar(java.time.LocalDateTime self)
Returns a generally equivalent instance of
Calendar . |
static java.util.Calendar |
toCalendar(java.time.LocalTime self)
Returns a generally equivalent instance of
Calendar . |
static java.util.Calendar |
toCalendar(java.time.OffsetDateTime self)
Returns a generally equivalent instance of
Calendar . |
static java.util.Calendar |
toCalendar(java.time.OffsetTime self)
Returns a generally equivalent instance of
Calendar . |
static java.util.Calendar |
toCalendar(java.time.ZonedDateTime self)
Returns a generally equivalent instance of
Calendar . |
static java.util.Date |
toDate(java.time.Instant self)
Returns a generally equivalent
Date according the number of milliseconds since the epoch,
adjusted into the system default time zone. |
static java.util.Date |
toDate(java.time.LocalDate self)
Returns an equivalent instance of
Date . |
static java.util.Date |
toDate(java.time.LocalDateTime self)
Returns a generally equivalent instance of
Date . |
static java.util.Date |
toDate(java.time.LocalTime self)
Returns a generally equivalent instance of
Date . |
static java.util.Date |
toDate(java.time.OffsetDateTime self)
Returns a generally equivalent instance of
Date . |
static java.util.Date |
toDate(java.time.OffsetTime self)
Returns a generally equivalent instance of
Date . |
static java.util.Date |
toDate(java.time.ZonedDateTime self)
Returns a generally equivalent instance of
Date . |
static java.time.DayOfWeek |
toDayOfWeek(java.util.Calendar self)
Converts the Calendar to a corresponding
DayOfWeek . |
static java.time.DayOfWeek |
toDayOfWeek(java.util.Date self)
Converts the Date to a corresponding
DayOfWeek . |
static java.time.Instant |
toInstant(java.util.Calendar self)
Convenience method for converting a Calendar to a corresponding
Instant . |
static java.time.LocalDate |
toLocalDate(java.util.Date self)
Converts the Date to a corresponding
LocalDate . |
static java.time.LocalDateTime |
toLocalDateTime(java.util.Calendar self)
Converts the Calendar to a corresponding
LocalDateTime . |
static java.time.LocalDateTime |
toLocalDateTime(java.util.Date self)
Converts the Date to a corresponding
LocalDateTime . |
static java.time.LocalTime |
toLocalTime(java.util.Calendar self)
Converts the Calendar to a corresponding
LocalTime . |
static java.time.LocalTime |
toLocalTime(java.util.Date self)
Converts the Date to a corresponding
LocalTime . |
static java.time.Month |
toMonth(java.util.Calendar self)
Converts the Calendar to a corresponding
Month . |
static java.time.Month |
toMonth(java.util.Date self)
Converts the Date to a corresponding
Month . |
static java.time.MonthDay |
toMonthDay(java.util.Calendar self)
Converts the Calendar to a corresponding
MonthDay . |
static java.time.MonthDay |
toMonthDay(java.util.Date self)
Converts the Date to a corresponding
MonthDay . |
static java.time.OffsetDateTime |
toOffsetDateTime(java.util.Calendar self)
Converts the Calendar to a corresponding
OffsetDateTime . |
static java.time.OffsetDateTime |
toOffsetDateTime(java.util.Date self)
Converts the Date to a corresponding
OffsetDateTime . |
static java.time.OffsetTime |
toOffsetTime(java.util.Calendar self)
Converts the Calendar to a corresponding
OffsetTime . |
static java.time.OffsetTime |
toOffsetTime(java.util.Date self)
Converts the Date to a corresponding
OffsetTime . |
static java.util.TimeZone |
toTimeZone(java.time.ZoneId self)
Returns a
TimeZone equivalent to this zone. |
static java.util.TimeZone |
toTimeZone(java.time.ZoneOffset self)
Returns a generally equivalent
TimeZone . |
static java.time.Year |
toYear(java.util.Calendar self)
Converts the Calendar to a corresponding
Year . |
static java.time.Year |
toYear(java.util.Date self)
Converts the Date to a corresponding
Year . |
static java.time.YearMonth |
toYearMonth(java.util.Calendar self)
Converts the Calendar to a corresponding
YearMonth . |
static java.time.YearMonth |
toYearMonth(java.util.Date self)
Converts the Date to a corresponding
YearMonth . |
static java.time.ZonedDateTime |
toZonedDateTime(java.util.Calendar self)
Converts the Calendar to a corresponding
ZonedDateTime . |
static java.time.ZonedDateTime |
toZonedDateTime(java.util.Date self)
Converts the Date to a corresponding
ZonedDateTime . |
static java.time.ZoneOffset |
toZoneOffset(java.util.TimeZone self)
Converts the TimeZone to a corresponding
ZoneOffset . |
static java.time.ZoneOffset |
toZoneOffset(java.util.TimeZone self,
java.time.Instant instant)
Converts this TimeZone to a corresponding
ZoneOffset . |
static void |
upto(java.time.temporal.Temporal from,
java.time.temporal.Temporal to,
Closure closure)
Iterates from this to the
to Temporal , inclusive, incrementing by one
unit each iteration, calling the closure once per iteration. |
static void |
upto(java.time.temporal.Temporal from,
java.time.temporal.Temporal to,
java.time.temporal.TemporalUnit unit,
Closure closure)
Iterates from this to the
to Temporal , inclusive, incrementing by one
unit each iteration, calling the closure once per iteration. |
public static void upto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, Closure closure)
to
Temporal
, inclusive, incrementing by one
unit each iteration, calling the closure once per iteration. The closure may accept a single
Temporal
argument.
The particular unit incremented by depends on the specific sub-type of Temporal
.
Most sub-types use a unit of ChronoUnit.SECONDS
except for
ChronoLocalDate
and its sub-types use ChronoUnit.DAYS
.
YearMonth
uses ChronoUnit.MONTHS
.
Year
uses ChronoUnit.YEARS
.
from
- the starting Temporalto
- the ending Temporalclosure
- the zero or one-argument closure to callGroovyRuntimeException
- if this value is later than to
GroovyRuntimeException
- if to
is a different type than thispublic static void upto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, java.time.temporal.TemporalUnit unit, Closure closure)
to
Temporal
, inclusive, incrementing by one
unit
each iteration, calling the closure once per iteration. The closure may accept a single
Temporal
argument.
If the unit is too large to iterate to the second Temporal exactly, such as iterating from two LocalDateTimes
that are seconds apart using ChronoUnit.DAYS
as the unit, the iteration will cease
as soon as the current value of the iteration is later than the second Temporal argument. The closure will
not be called with any value later than the to
value.
from
- the starting Temporalto
- the ending Temporalunit
- the TemporalUnit to increment byclosure
- the zero or one-argument closure to callGroovyRuntimeException
- if this value is later than to
GroovyRuntimeException
- if to
is a different type than thispublic static void downto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, Closure closure)
to
Temporal
, inclusive, decrementing by one
unit each iteration, calling the closure once per iteration. The closure may accept a single
Temporal
argument.
The particular unit decremented by depends on the specific sub-type of Temporal
.
Most sub-types use a unit of ChronoUnit.SECONDS
except for
ChronoLocalDate
and its sub-types use ChronoUnit.DAYS
.
YearMonth
uses ChronoUnit.MONTHS
.
Year
uses ChronoUnit.YEARS
.
from
- the starting Temporalto
- the ending Temporalclosure
- the zero or one-argument closure to callGroovyRuntimeException
- if this value is earlier than to
GroovyRuntimeException
- if to
is a different type than thispublic static void downto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, java.time.temporal.TemporalUnit unit, Closure closure)
to
Temporal
, inclusive, decrementing by one
unit
each iteration, calling the closure once per iteration. The closure may accept a single
Temporal
argument.
If the unit is too large to iterate to the second Temporal exactly, such as iterating from two LocalDateTimes
that are seconds apart using ChronoUnit.DAYS
as the unit, the iteration will cease
as soon as the current value of the iteration is earlier than the second Temporal argument. The closure will
not be called with any value earlier than the to
value.
from
- the starting Temporalto
- the ending Temporalunit
- the TemporalUnit to increment byclosure
- the zero or one-argument closure to callGroovyRuntimeException
- if this value is earlier than to
GroovyRuntimeException
- if to
is a different type than thispublic static java.time.temporal.TemporalAmount rightShift(java.time.temporal.Temporal self, java.time.temporal.Temporal other)
Duration
or Period
between this (inclusive) and the other
Temporal
(exclusive).
A Period will be returned for types Year
, YearMonth
, and
ChronoLocalDate
; otherwise, a Duration will be returned.
Note: if the Temporal is a ChronoLocalDate but not a LocalDate
, a general
ChronoPeriod
will be returned as per the return type of the method
ChronoLocalDate.until(ChronoLocalDate)
.
self
- a Temporalother
- another Temporal of the same typepublic static long getAt(java.time.temporal.TemporalAccessor self, java.time.temporal.TemporalField field)
TemporalAccessor.getLong(java.time.temporal.TemporalField)
method.self
- a TemporalAccessorfield
- a non-null TemporalFieldjava.time.DateTimeException
- if a value for the field cannot be obtainedjava.time.temporal.UnsupportedTemporalTypeException
- if the field is not supportedjava.lang.ArithmeticException
- if numeric overflow occurspublic static long getAt(java.time.temporal.TemporalAmount self, java.time.temporal.TemporalUnit unit)
TemporalAmount.get(TemporalUnit)
method.self
- a TemporalAmountunit
- a non-null TemporalUnitjava.time.DateTimeException
- if a value for the field cannot be obtainedjava.time.temporal.UnsupportedTemporalTypeException
- if the field is not supportedjava.lang.ArithmeticException
- if numeric overflow occurspublic static java.time.Duration plus(java.time.Duration self, long seconds)
Duration
that is seconds
seconds longer than this duration.self
- a Durationseconds
- the number of seconds to addpublic static java.time.Duration minus(java.time.Duration self, long seconds)
Duration
that is seconds
seconds shorter that this duration.self
- a Durationseconds
- the number of seconds to subtractpublic static java.time.Duration next(java.time.Duration self)
Duration
that is one second longer than this duration.self
- a Durationpublic static java.time.Duration previous(java.time.Duration self)
Duration
that is one second shorter than this duration.self
- a Durationpublic static java.time.Duration negative(java.time.Duration self)
Duration.negated()
method.self
- a Durationpublic static java.time.Duration positive(java.time.Duration self)
Duration.abs()
method.self
- a Durationpublic static java.time.Duration multiply(java.time.Duration self, long scalar)
Duration.multipliedBy(long)
method.self
- a Durationscalar
- the value to multiply bypublic static java.time.Duration div(java.time.Duration self, long scalar)
Duration.dividedBy(long)
method.self
- a Durationscalar
- the value to divide bypublic static boolean isPositive(java.time.Duration self)
self
- a Durationpublic static boolean isNonnegative(java.time.Duration self)
self
- a Durationpublic static boolean isNonpositive(java.time.Duration self)
self
- a Durationpublic static java.time.Instant plus(java.time.Instant self, long seconds)
Instant
that is seconds
seconds after this instant.self
- an Instantseconds
- the number of seconds to addpublic static java.time.Instant minus(java.time.Instant self, long seconds)
Instant
that is seconds
seconds before this instant.self
- an Instantseconds
- the number of seconds to subtractpublic static java.time.Instant next(java.time.Instant self)
Instant
that is one second after this instant.self
- an Instantpublic static java.time.Instant previous(java.time.Instant self)
Instant
that one second before this instant.self
- an Instantpublic static java.util.Date toDate(java.time.Instant self)
Date
according the number of milliseconds since the epoch,
adjusted into the system default time zone.self
- an Instantpublic static java.util.Calendar toCalendar(java.time.Instant self)
Calendar
in the GMT time zone, truncated to milliseconds.self
- an Instantpublic static java.lang.String format(java.time.LocalDate self, java.lang.String pattern)
DateTimeFormatter
pattern.self
- a LocalDatepattern
- the formatting patternDateTimeFormatter
public static java.lang.String format(java.time.LocalDate self, java.time.format.FormatStyle dateStyle)
FormatStyle
.self
- a LocalDatedateStyle
- the FormatStyleDateTimeFormatter
public static java.lang.String getDateString(java.time.LocalDate self)
DateTimeFormatter.ISO_LOCAL_DATE
formatter.self
- a LocalDateDateTimeFormatter
public static java.time.LocalDate plus(java.time.LocalDate self, long days)
LocalDate
that is days
days after this date.self
- a LocalDatedays
- the number of days to addpublic static java.time.LocalDate minus(java.time.LocalDate self, long days)
LocalDate
that is days
days before this date.self
- a LocalDatedays
- the number of days to subtractpublic static java.time.LocalDate next(java.time.LocalDate self)
LocalDate
one day after this date.self
- a LocalDatepublic static java.time.LocalDate previous(java.time.LocalDate self)
LocalDate
one day before this date.self
- a LocalDatepublic static java.time.Period rightShift(java.time.LocalDate self, java.time.LocalDate other)
Period
equivalent to the time between this date (inclusive)
and the provided LocalDate
(exclusive).self
- a LocalDateother
- another LocalDatepublic static java.time.LocalDateTime leftShift(java.time.LocalDate self, java.time.LocalTime time)
LocalDateTime
from this date and the provided LocalTime
.self
- a LocalDatetime
- a LocalTimepublic static java.time.OffsetDateTime leftShift(java.time.LocalDate self, java.time.OffsetTime time)
OffsetDateTime
from this date and the provided OffsetTime
.self
- a LocalDatetime
- an OffsetTimepublic static java.util.Date toDate(java.time.LocalDate self)
Date
.
The time portion of the returned date is cleared.self
- a LocalDatepublic static java.util.Calendar toCalendar(java.time.LocalDate self)
Calendar
.
The time portion of the returned calendar is cleared and the time zone is the current system default.self
- a LocalDatepublic static java.lang.String format(java.time.LocalDateTime self, java.lang.String pattern)
DateTimeFormatter
pattern.self
- a LocalDateTimepattern
- the formatting patternDateTimeFormatter
public static java.lang.String format(java.time.LocalDateTime self, java.time.format.FormatStyle dateTimeStyle)
FormatStyle
.self
- a LocalDateTimedateTimeStyle
- the FormatStyleDateTimeFormatter
public static java.lang.String getDateTimeString(java.time.LocalDateTime self)
DateTimeFormatter.ISO_LOCAL_DATE_TIME
formatter.self
- a LocalDateTimeDateTimeFormatter
public static java.lang.String getDateString(java.time.LocalDateTime self)
DateTimeFormatter.ISO_LOCAL_DATE
formatter.self
- a LocalDateTimeDateTimeFormatter
public static java.lang.String getTimeString(java.time.LocalDateTime self)
DateTimeFormatter.ISO_LOCAL_TIME
formatter.self
- a LocalDateTimeDateTimeFormatter
public static java.time.LocalDateTime clearTime(java.time.LocalDateTime self)
LocalDateTime
with the time portion cleared.self
- a LocalDateTimepublic static java.time.LocalDateTime plus(java.time.LocalDateTime self, long seconds)
LocalDateTime
that is seconds
seconds after this date/time.self
- a LocalDateTimeseconds
- the number of seconds to addpublic static java.time.LocalDateTime minus(java.time.LocalDateTime self, long seconds)
LocalDateTime
that is seconds
seconds before this date/time.self
- a LocalDateTimeseconds
- the number of seconds to subtractpublic static java.time.LocalDateTime next(java.time.LocalDateTime self)
LocalDateTime
that is one second after this date/time.self
- a LocalDateTimepublic static java.time.LocalDateTime previous(java.time.LocalDateTime self)
LocalDateTime
that is one second before this date/time.self
- a LocalDateTimepublic static java.time.OffsetDateTime leftShift(java.time.LocalDateTime self, java.time.ZoneOffset offset)
OffsetDateTime
of this date/time and the provided ZoneOffset
.self
- a LocalDateTimeoffset
- a ZoneOffsetpublic static java.time.ZonedDateTime leftShift(java.time.LocalDateTime self, java.time.ZoneId zone)
OffsetDateTime
of this date/time and the provided ZoneId
.self
- a LocalDateTimezone
- a ZoneIdpublic static java.util.Date toDate(java.time.LocalDateTime self)
Date
.
The time value of the returned date is truncated to milliseconds.self
- a LocalDateTimepublic static java.util.Calendar toCalendar(java.time.LocalDateTime self)
Calendar
.
The time value of the returned calendar is truncated to milliseconds and the
time zone is the current system default.self
- a LocalDateTimepublic static java.lang.String format(java.time.LocalTime self, java.lang.String pattern)
DateTimeFormatter
pattern.self
- a LocalDateTimepattern
- the formatting patternDateTimeFormatter
public static java.lang.String format(java.time.LocalTime self, java.time.format.FormatStyle timeStyle)
FormatStyle
.self
- a LocalTimetimeStyle
- the FormatStyleDateTimeFormatter
public static java.lang.String getTimeString(java.time.LocalTime self)
DateTimeFormatter.ISO_LOCAL_TIME
formatter.self
- a LocalTimeDateTimeFormatter
public static java.time.LocalTime plus(java.time.LocalTime self, long seconds)
LocalTime
that is seconds
seconds after this time.self
- a LocalTimeseconds
- the number of seconds to addpublic static java.time.LocalTime minus(java.time.LocalTime self, long seconds)
LocalTime
that is seconds
seconds before this time.self
- a LocalTimeseconds
- the number of seconds to subtractpublic static java.time.LocalTime next(java.time.LocalTime self)
LocalTime
that is one second after this time.self
- a LocalTimepublic static java.time.LocalTime previous(java.time.LocalTime self)
LocalTime
that is one second before this time.self
- a LocalTimepublic static java.time.LocalDateTime leftShift(java.time.LocalTime self, java.time.LocalDate date)
LocalDateTime
of this time and the provided LocalDate
.self
- a LocalTimedate
- a LocalDatepublic static java.time.OffsetTime leftShift(java.time.LocalTime self, java.time.ZoneOffset offset)
OffsetTime
of this time and the provided ZoneOffset
.self
- a LocalTimeoffset
- a ZoneOffsetpublic static java.util.Date toDate(java.time.LocalTime self)
Date
. The day-month-year value of the
returned date is today and the time is truncated to milliseconds.self
- a LocalTimepublic static java.util.Calendar toCalendar(java.time.LocalTime self)
Calendar
. The day-month-year value of the
returned calendar is today, the time is truncated to milliseconds, and the time zone is the current
system default.self
- a LocalTimepublic static java.time.LocalDate leftShift(java.time.MonthDay self, int year)
LocalDate
of this month/day and the provided year.self
- a MonthDayyear
- a yearpublic static java.time.LocalDate leftShift(java.time.MonthDay self, java.time.Year year)
LocalDate
of this month/day and the provided Year
.self
- a MonthDayyear
- a Yearpublic static java.lang.String format(java.time.OffsetDateTime self, java.lang.String pattern)
DateTimeFormatter
pattern.self
- an OffsetDateTimepattern
- the formatting patternDateTimeFormatter
public static java.lang.String format(java.time.OffsetDateTime self, java.time.format.FormatStyle dateTimeStyle)
FormatStyle
.self
- an OffsetDateTimedateTimeStyle
- the FormatStyleDateTimeFormatter
public static java.lang.String getDateTimeString(java.time.OffsetDateTime self)
DateTimeFormatter.ISO_OFFSET_DATE_TIME
formatter.self
- an OffsetDateTimeDateTimeFormatter
public static java.lang.String getDateString(java.time.OffsetDateTime self)
DateTimeFormatter.ISO_OFFSET_DATE
formatter.self
- an OffsetDateTimeDateTimeFormatter
public static java.lang.String getTimeString(java.time.OffsetDateTime self)
DateTimeFormatter.ISO_OFFSET_TIME
formatter.self
- an OffsetDateTimeDateTimeFormatter
public static java.time.OffsetDateTime clearTime(java.time.OffsetDateTime self)
OffsetDateTime
with the time portion cleared.self
- an OffsetDateTimepublic static java.time.OffsetDateTime plus(java.time.OffsetDateTime self, long seconds)
OffsetDateTime
that is seconds
seconds after this date/time.self
- an OffsetDateTimeseconds
- the number of seconds to addpublic static java.time.OffsetDateTime minus(java.time.OffsetDateTime self, long seconds)
OffsetDateTime
that is seconds
seconds before this date/time.self
- an OffsetDateTimeseconds
- the number of seconds to subtractpublic static java.time.OffsetDateTime next(java.time.OffsetDateTime self)
OffsetDateTime
one second after this date/time.self
- an OffsetDateTimepublic static java.time.OffsetDateTime previous(java.time.OffsetDateTime self)
OffsetDateTime
one second before this date/time.self
- an OffsetDateTimepublic static java.util.Date toDate(java.time.OffsetDateTime self)
Date
.
The time value of the returned date is truncated to milliseconds and will be
adjusted to the current system default time zone.self
- an OffsetDateTimepublic static java.util.Calendar toCalendar(java.time.OffsetDateTime self)
Calendar
.
The time value of the returned calendar is truncated to milliseconds and the time zone
is based on the offset of this date/time.self
- an OffsetDateTimepublic static java.lang.String format(java.time.OffsetTime self, java.lang.String pattern)
DateTimeFormatter
pattern.self
- an OffsetTimepattern
- the formatting patternDateTimeFormatter
public static java.lang.String format(java.time.OffsetTime self, java.time.format.FormatStyle timeStyle)
FormatStyle
.self
- an OffsetTimetimeStyle
- the FormatStyleDateTimeFormatter
public static java.lang.String getTimeString(java.time.OffsetTime self)
DateTimeFormatter.ISO_OFFSET_TIME
formatter.self
- an OffsetTimeDateTimeFormatter
public static java.time.OffsetTime plus(java.time.OffsetTime self, long seconds)
OffsetTime
that is seconds
seconds after this time.self
- an OffsetTimeseconds
- the number of seconds to addpublic static java.time.OffsetTime minus(java.time.OffsetTime self, long seconds)
OffsetTime
that is seconds
seconds before this time.self
- an OffsetTimeseconds
- the number of seconds to subtractpublic static java.time.OffsetTime next(java.time.OffsetTime self)
OffsetTime
that is one second after this time.self
- an OffsetTimepublic static java.time.OffsetTime previous(java.time.OffsetTime self)
OffsetTime
that is one second before this time.self
- an OffsetTimepublic static java.time.OffsetDateTime leftShift(java.time.OffsetTime self, java.time.LocalDate date)
OffsetDateTime
of this time and the provided LocalDate
.self
- an OffsetTimedate
- a LocalDatepublic static java.util.Date toDate(java.time.OffsetTime self)
Date
.
The time value of the returned date is truncated to milliseconds and will be
adjusted to the current system default time zone.self
- an OffsetTimepublic static java.util.Calendar toCalendar(java.time.OffsetTime self)
Calendar
.
The date value of the returned calendar is now, the time value is truncated to milliseconds,
and the time zone is based on the offset of this time.self
- an OffsetTimepublic static java.time.Period plus(java.time.Period self, long days)
Period
that is days
days longer than this period.
No normalization is performed.self
- a Perioddays
- the number of days to increase this Period bypublic static java.time.Period minus(java.time.Period self, long days)
Period
that is days
days shorter than this period.
No normalization is performed.self
- a Perioddays
- the number of days to decrease this Period bypublic static java.time.Period next(java.time.Period self)
Period
that is one day longer than this period.
No normalization is performed.self
- a Periodpublic static java.time.Period previous(java.time.Period self)
Period
that is one day shorter than this period.
No normalization is performed.self
- a Periodpublic static java.time.Period negative(java.time.Period self)
Period.negated()
method.self
- a Periodpublic static java.time.Period positive(java.time.Period self)
Period
with all unit values positive.
For example, a period of "2 years, -3 months, and -4 days" would result in a period of
"2 years, 3 months, and 4 days." No normalization is performed.self
- a Periodpublic static java.time.Period multiply(java.time.Period self, int scalar)
Period.multipliedBy(int)
method.self
- a Periodscalar
- a scalar to multiply each unit bypublic static boolean isPositive(java.time.chrono.ChronoPeriod self)
self
- a ChronoPeriodpublic static boolean isNonnegative(java.time.chrono.ChronoPeriod self)
self
- a ChronoPeriodpublic static boolean isNonpositive(java.time.chrono.ChronoPeriod self)
self
- a ChronoPeriodpublic static java.time.Year plus(java.time.Year self, long years)
Year
that is years
years after this year.self
- a Yearyears
- the number of years to addpublic static java.time.Year minus(java.time.Year self, long years)
Year
that is years
years before this year.self
- a Yearyears
- the number of years to subtractpublic static java.time.Year next(java.time.Year self)
Year
after this year.self
- a Yearpublic static java.time.Year previous(java.time.Year self)
Year
before this year.self
- a Yearpublic static java.time.Period rightShift(java.time.Year self, java.time.Year year)
Period
between the first day of this year (inclusive) and the first day of the
provided Year
(exclusive).self
- a Yearyear
- another Yearpublic static java.time.YearMonth leftShift(java.time.Year self, java.time.Month month)
YearMonth
of this year and the provided Month
.self
- a Yearmonth
- a Monthpublic static java.time.LocalDate leftShift(java.time.Year self, java.time.MonthDay monthDay)
LocalDate
of this year on the given MonthDay
.self
- a YearmonthDay
- a MonthDaypublic static int getEra(java.time.Year self)
Year.get(java.time.temporal.TemporalField)
method with a
ChronoField.ERA
argument.
Returns the era of the year, which is currently either 0 (BC) or 1 (AD).
self
- a Yearpublic static int getYearOfEra(java.time.Year self)
Year.get(java.time.temporal.TemporalField)
method with a
ChronoField.YEAR_OF_ERA
argument.
Since Year=0 represents 1 BC, the yearOfEra value of Year=0 is 1, Year=-1 is 2, and so on.
self
- a Yearpublic static java.time.YearMonth plus(java.time.YearMonth self, long months)
YearMonth
that is months
months after this year/month.self
- a YearMonthmonths
- the number of months to addpublic static java.time.YearMonth minus(java.time.YearMonth self, long months)
YearMonth
that is months
months before this year/month.self
- a YearMonthmonths
- the number of months to subtractpublic static java.time.YearMonth next(java.time.YearMonth self)
YearMonth
that is the month after this year/month.self
- a YearMonthpublic static java.time.YearMonth previous(java.time.YearMonth self)
YearMonth
that is the month before this year/month.self
- a YearMonthpublic static java.time.LocalDate leftShift(java.time.YearMonth self, int dayOfMonth)
LocalDate
of this year/month and the given day of the month.self
- a YearMonthdayOfMonth
- a day of the monthpublic static java.time.Period rightShift(java.time.YearMonth self, java.time.YearMonth other)
Period
of time between the first day of this year/month (inclusive) and the
given YearMonth
(exclusive).self
- a YearMonthother
- another YearMonthpublic static java.lang.String format(java.time.ZonedDateTime self, java.lang.String pattern)
DateTimeFormatter
pattern.self
- a ZonedDateTimepattern
- the formatting patternDateTimeFormatter
public static java.lang.String format(java.time.ZonedDateTime self, java.time.format.FormatStyle dateTimeStyle)
FormatStyle
.self
- a ZonedDateTimedateTimeStyle
- the FormatStyleDateTimeFormatter
public static java.lang.String getDateTimeString(java.time.ZonedDateTime self)
DateTimeFormatter.ISO_LOCAL_DATE_TIME
formatter
and appends the zone's short name, e.g. 2018-03-10T14:34:55.144EST
.self
- a ZonedDateTimeDateTimeFormatter
public static java.lang.String getDateString(java.time.ZonedDateTime self)
DateTimeFormatter.ISO_LOCAL_DATE
formatter
and appends the zone's short name, e.g. 2018-03-10EST
.self
- a ZonedDateTimeDateTimeFormatter
public static java.lang.String getTimeString(java.time.ZonedDateTime self)
DateTimeFormatter.ISO_LOCAL_TIME
formatter
and appends the zone's short name, e.g. 14:34:55.144EST
.self
- a ZonedDateTimeDateTimeFormatter
public static java.time.ZonedDateTime clearTime(java.time.ZonedDateTime self)
ZonedDateTime
with the time portion cleared.self
- a ZonedDateTimepublic static java.time.ZonedDateTime plus(java.time.ZonedDateTime self, long seconds)
ZonedDateTime
that is seconds
seconds after this date/time.self
- an ZonedDateTimeseconds
- the number of seconds to addpublic static java.time.ZonedDateTime minus(java.time.ZonedDateTime self, long seconds)
ZonedDateTime
that is seconds
seconds before this date/time.self
- a ZonedDateTimeseconds
- the number of seconds to subtractpublic static java.time.ZonedDateTime next(java.time.ZonedDateTime self)
ZonedDateTime
that is one second after this date/time.self
- a ZonedDateTimepublic static java.time.ZonedDateTime previous(java.time.ZonedDateTime self)
ZonedDateTime
that is one second before this date/time.self
- a ZonedDateTimepublic static java.util.Date toDate(java.time.ZonedDateTime self)
Date
.
The time value of the returned date is truncated to milliseconds and will be
adjusted to the current system default time zone.self
- a ZonedDateTimepublic static java.util.Calendar toCalendar(java.time.ZonedDateTime self)
Calendar
.
The time value of the returned calendar is truncated to milliseconds and the time zone
is determined by the zone of this date/time.self
- an ZonedDateTimepublic static java.util.TimeZone toTimeZone(java.time.ZoneId self)
TimeZone
equivalent to this zone.self
- a ZoneIdpublic static java.lang.String getFullName(java.time.ZoneId self)
TextStyle.FULL
text style.self
- a ZoneIdpublic static java.lang.String getFullName(java.time.ZoneId self, java.util.Locale locale)
TextStyle.FULL
text style
for the provided Locale
.self
- a ZoneIdlocale
- a Localepublic static java.lang.String getShortName(java.time.ZoneId self)
TextStyle.SHORT
text style.self
- a ZoneIdpublic static java.lang.String getShortName(java.time.ZoneId self, java.util.Locale locale)
TextStyle.SHORT
text style
for the provided Locale
.self
- a ZoneIdlocale
- a Localepublic static java.time.ZoneOffset getOffset(java.time.ZoneId self)
ZoneOffset
for this zone as of now.self
- a ZoneIdpublic static java.time.ZoneOffset getOffset(java.time.ZoneId self, java.time.Instant instant)
ZoneOffset
for this zone as of the provided Instant
.self
- a ZoneIdinstant
- an Instantpublic static java.time.ZonedDateTime leftShift(java.time.ZoneId self, java.time.LocalDateTime dateTime)
ZonedDateTime
of this zone and the given LocalDateTime
.self
- a ZoneIdpublic static java.util.TimeZone toTimeZone(java.time.ZoneOffset self)
TimeZone
. The offset will be truncated to minutes.self
- a ZoneOffsetpublic static int getHours(java.time.ZoneOffset self)
self
- a ZoneOffsetpublic static int getMinutes(java.time.ZoneOffset self)
self
- a ZoneOffsetpublic static int getSeconds(java.time.ZoneOffset self)
def offset = ZoneOffset.ofHoursMinutesSeconds(0, 1, 1) assert offset.seconds == 1 assert offset.totalSeconds == 61
If the offset's total seconds are negative, a negative value will be returned.
self
- a ZoneOffsetpublic static long getAt(java.time.ZoneOffset self, java.time.temporal.TemporalField field)
ZoneOffset.getLong(java.time.temporal.TemporalField)
method.self
- a ZoneOffsetfield
- a TemporalFieldpublic static java.time.OffsetDateTime leftShift(java.time.ZoneOffset self, java.time.LocalDateTime dateTime)
OffsetDateTime
of this offset and the provided LocalDateTime
.self
- a ZoneOffsetdateTime
- a LocalDateTimepublic static java.time.OffsetTime leftShift(java.time.ZoneOffset self, java.time.LocalTime time)
OffsetDateTime
of this offset and the provided LocalTime
.self
- a ZoneOffsettime
- a LocalTimepublic static java.time.DayOfWeek plus(java.time.DayOfWeek self, int days)
DayOfWeek
that is days
many days after this day of the week.self
- a DayOfWeekdays
- the number of days to move forwardpublic static java.time.DayOfWeek minus(java.time.DayOfWeek self, int days)
DayOfWeek
that is days
many days before this day of the week.self
- a DayOfWeekdays
- the number of days to move backpublic static boolean isWeekend(java.time.DayOfWeek self)
true
if this day of the week is a weekend day (Saturday or Sunday).self
- a DayOfWeekpublic static boolean isWeekday(java.time.DayOfWeek self)
true
if the DayOfWeek is a weekday.public static java.time.Month plus(java.time.Month self, int months)
Month
that is months
months after this month.self
- a Monthmonths
- the number of months move forwardpublic static java.time.Month minus(java.time.Month self, int months)
Month
that is months
months before this month.self
- a Monthmonths
- the number of months to move backpublic static java.time.MonthDay leftShift(java.time.Month self, int dayOfMonth)
MonthDay
at the provided day of the month.self
- a MonthdayOfMonth
- a day of the monthpublic static java.time.YearMonth leftShift(java.time.Month self, java.time.Year year)
YearMonth
at the provided Year
.self
- a Monthyear
- a Yearpublic static java.time.ZoneOffset getZoneOffset(java.util.Calendar self)
ZoneOffset
.self
- a Calendarpublic static java.time.ZoneOffset getZoneOffset(java.util.Date self)
ZoneOffset
,
which will typically be system's default offset.self
- a Datepublic static java.time.ZoneId getZoneId(java.util.Calendar self)
self
- a Calendarpublic static java.time.ZoneId getZoneId(java.util.Date self)
ZoneId
. This will
typically be the system's default ZoneId.self
- a Datepublic static java.time.Year toYear(java.util.Calendar self)
Year
. If the Calendar has a different
time zone than the system default, the Year will be adjusted into the default time zone.self
- a Calendarpublic static java.time.Year toYear(java.util.Date self)
Year
.self
- a Datepublic static java.time.Month toMonth(java.util.Calendar self)
Month
. If the Calendar has a different
time zone than the system default, the Month will be adjusted into the default time zone.self
- a Calendarpublic static java.time.Month toMonth(java.util.Date self)
Month
.self
- a Datepublic static java.time.MonthDay toMonthDay(java.util.Calendar self)
MonthDay
. If the Calendar has a different
time zone than the system default, the MonthDay will be adjusted into the default time zone.self
- a Calendarpublic static java.time.MonthDay toMonthDay(java.util.Date self)
MonthDay
.self
- a Datepublic static java.time.YearMonth toYearMonth(java.util.Calendar self)
YearMonth
. If the Calendar has a different
time zone than the system default, the YearMonth will be adjusted into the default time zone.self
- a Calendarpublic static java.time.YearMonth toYearMonth(java.util.Date self)
YearMonth
.self
- a Datepublic static java.time.DayOfWeek toDayOfWeek(java.util.Calendar self)
DayOfWeek
. If the Calendar has a different
time zone than the system default, the DayOfWeek will be adjusted into the default time zone.self
- a Calendarpublic static java.time.DayOfWeek toDayOfWeek(java.util.Date self)
DayOfWeek
.self
- a Datepublic static java.time.LocalDate toLocalDate(java.util.Date self)
LocalDate
.self
- a Datepublic static java.time.LocalTime toLocalTime(java.util.Calendar self)
LocalTime
. If the Calendar has a different
time zone than the system default, the LocalTime will be adjusted into the default time zone.self
- a Calendarpublic static java.time.LocalTime toLocalTime(java.util.Date self)
LocalTime
.self
- a Datepublic static java.time.LocalDateTime toLocalDateTime(java.util.Calendar self)
LocalDateTime
. If the Calendar has a different
time zone than the system default, the LocalDateTime will be adjusted into the default time zone.self
- a Calendarpublic static java.time.LocalDateTime toLocalDateTime(java.util.Date self)
LocalDateTime
.self
- a Datepublic static java.time.ZonedDateTime toZonedDateTime(java.util.Calendar self)
Converts the Calendar to a corresponding ZonedDateTime
.
Note that
GregorianCalendar
has a GregorianCalendar.toZonedDateTime()
method,
which is commonly the specific type of Calendar in use.
self
- a Calendarpublic static java.time.ZonedDateTime toZonedDateTime(java.util.Date self)
ZonedDateTime
.self
- a Datepublic static java.time.OffsetDateTime toOffsetDateTime(java.util.Calendar self)
OffsetDateTime
.self
- a Calendarpublic static java.time.OffsetDateTime toOffsetDateTime(java.util.Date self)
OffsetDateTime
.self
- a Datepublic static java.time.OffsetTime toOffsetTime(java.util.Calendar self)
OffsetTime
.self
- a Calendarpublic static java.time.OffsetTime toOffsetTime(java.util.Date self)
OffsetTime
.self
- a Datepublic static java.time.Instant toInstant(java.util.Calendar self)
Instant
.self
- a Calendarpublic static java.time.ZoneOffset toZoneOffset(java.util.TimeZone self)
ZoneOffset
. The offset is determined
using the current date/time.self
- a TimeZonepublic static java.time.ZoneOffset toZoneOffset(java.util.TimeZone self, java.time.Instant instant)
ZoneOffset
. The offset is determined
using the date/time of specified Instant.self
- a TimeZone