Class DateTimeExtensions
public class DateTimeExtensions
extends java.lang.Object
-
Method Summary
Modifier and Type Method Description static java.time.LocalDateTime
clearTime(java.time.LocalDateTime self)
Returns aLocalDateTime
with the time portion cleared.static java.time.OffsetDateTime
clearTime(java.time.OffsetDateTime self)
Returns anOffsetDateTime
with the time portion cleared.static java.time.ZonedDateTime
clearTime(java.time.ZonedDateTime self)
Returns anZonedDateTime
with the time portion cleared.static java.time.Duration
div(java.time.Duration self, long scalar)
Supports the division operator; equivalent to calling theDuration.dividedBy(long)
method.static void
downto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, Closure closure)
Iterates from this to theto
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 theto
Temporal
, inclusive, decrementing by oneunit
each iteration, calling the closure once per iteration.static java.lang.String
format(java.time.LocalDate self, java.lang.String pattern)
Formats this date with the providedDateTimeFormatter
pattern.static java.lang.String
format(java.time.LocalDate self, java.time.format.FormatStyle dateStyle)
Formats this date in the provided, localizedFormatStyle
.static java.lang.String
format(java.time.LocalDateTime self, java.lang.String pattern)
Formats this date/time with the providedDateTimeFormatter
pattern.static java.lang.String
format(java.time.LocalDateTime self, java.time.format.FormatStyle dateTimeStyle)
Formats this date/time in the provided, localizedFormatStyle
.static java.lang.String
format(java.time.LocalTime self, java.lang.String pattern)
Formats this time with the providedDateTimeFormatter
pattern.static java.lang.String
format(java.time.LocalTime self, java.time.format.FormatStyle timeStyle)
Formats this time in the provided, localizedFormatStyle
.static java.lang.String
format(java.time.OffsetDateTime self, java.lang.String pattern)
Formats this date/time with the providedDateTimeFormatter
pattern.static java.lang.String
format(java.time.OffsetDateTime self, java.time.format.FormatStyle dateTimeStyle)
Formats this date/time in the provided, localizedFormatStyle
.static java.lang.String
format(java.time.OffsetTime self, java.lang.String pattern)
Formats this time with the providedDateTimeFormatter
pattern.static java.lang.String
format(java.time.OffsetTime self, java.time.format.FormatStyle timeStyle)
Formats this time in the provided, localizedFormatStyle
.static java.lang.String
format(java.time.ZonedDateTime self, java.lang.String pattern)
Formats this date/time with the providedDateTimeFormatter
pattern.static java.lang.String
format(java.time.ZonedDateTime self, java.time.format.FormatStyle dateTimeStyle)
Formats this date/time in the provided, localizedFormatStyle
.static long
getAt(java.time.temporal.TemporalAccessor self, java.time.temporal.TemporalField field)
Supports the getAt operator; equivalent to calling theTemporalAccessor.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 theTemporalAmount.get(TemporalUnit)
method.static long
getAt(java.time.ZoneOffset self, java.time.temporal.TemporalField field)
Supports the getAt operator; equivalent to calling theZoneOffset.getLong(java.time.temporal.TemporalField)
method.static java.lang.String
getDateString(java.time.LocalDate self)
Formats this date with theDateTimeFormatter.ISO_LOCAL_DATE
formatter.static java.lang.String
getDateString(java.time.LocalDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_LOCAL_DATE
formatter.static java.lang.String
getDateString(java.time.OffsetDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_OFFSET_DATE
formatter.static java.lang.String
getDateString(java.time.ZonedDateTime self)
Formats this date/time with theDateTimeFormatter.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 theDateTimeFormatter.ISO_LOCAL_DATE_TIME
formatter.static java.lang.String
getDateTimeString(java.time.OffsetDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_OFFSET_DATE_TIME
formatter.static java.lang.String
getDateTimeString(java.time.ZonedDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_LOCAL_DATE_TIME
formatter and appends the zone's short name, e.g.static int
getEra(java.time.Year self)
Equivalent to calling theYear.get(java.time.temporal.TemporalField)
method with aChronoField.ERA
argument.static java.lang.String
getFullName(java.time.ZoneId self)
Returns the name of this zone formatted according to theTextStyle.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 theTextStyle.FULL
text style for the providedLocale
.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 aZoneOffset
for this zone as of now.static java.time.ZoneOffset
getOffset(java.time.ZoneId self, java.time.Instant instant)
Returns aZoneOffset
for this zone as of the providedInstant
.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 theTextStyle.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 theTextStyle.SHORT
text style for the providedLocale
.static java.lang.String
getTimeString(java.time.LocalDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_LOCAL_TIME
formatter.static java.lang.String
getTimeString(java.time.LocalTime self)
Formats this time with theDateTimeFormatter.ISO_LOCAL_TIME
formatter.static java.lang.String
getTimeString(java.time.OffsetDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_OFFSET_TIME
formatter.static java.lang.String
getTimeString(java.time.OffsetTime self)
Formats this time with theDateTimeFormatter.ISO_OFFSET_TIME
formatter.static java.lang.String
getTimeString(java.time.ZonedDateTime self)
Formats this date/time with theDateTimeFormatter.ISO_LOCAL_TIME
formatter and appends the zone's short name, e.g.static int
getYearOfEra(java.time.Year self)
Equivalent to calling theYear.get(java.time.temporal.TemporalField)
method with aChronoField.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 aZoneId
.static java.time.ZoneOffset
getZoneOffset(java.util.Calendar self)
Returns the Time Zone offset of the Calendar as aZoneOffset
.static java.time.ZoneOffset
getZoneOffset(java.util.Date self)
Returns the Time Zone offset of the Date as aZoneOffset
, 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)
Returnstrue
if the DayOfWeek is a weekday.static boolean
isWeekend(java.time.DayOfWeek self)
Returnstrue
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 aLocalDateTime
from this date and the providedLocalTime
.static java.time.OffsetDateTime
leftShift(java.time.LocalDate self, java.time.OffsetTime time)
Returns aOffsetDateTime
from this date and the providedOffsetTime
.static java.time.ZonedDateTime
leftShift(java.time.LocalDateTime self, java.time.ZoneId zone)
Returns aOffsetDateTime
of this date/time and the providedZoneId
.static java.time.OffsetDateTime
leftShift(java.time.LocalDateTime self, java.time.ZoneOffset offset)
Returns anOffsetDateTime
of this date/time and the providedZoneOffset
.static java.time.LocalDateTime
leftShift(java.time.LocalTime self, java.time.LocalDate date)
Returns aLocalDateTime
of this time and the providedLocalDate
.static java.time.OffsetTime
leftShift(java.time.LocalTime self, java.time.ZoneOffset offset)
Returns anOffsetTime
of this time and the providedZoneOffset
.static java.time.LocalDate
leftShift(java.time.MonthDay self, int year)
Returns aLocalDate
of this month/day and the provided year.static java.time.LocalDate
leftShift(java.time.MonthDay self, java.time.Year year)
Returns aLocalDate
of this month/day and the providedYear
.static java.time.MonthDay
leftShift(java.time.Month self, int dayOfMonth)
Creates aMonthDay
at the provided day of the month.static java.time.YearMonth
leftShift(java.time.Month self, java.time.Year year)
Creates aYearMonth
at the providedYear
.static java.time.OffsetDateTime
leftShift(java.time.OffsetTime self, java.time.LocalDate date)
Returns anOffsetDateTime
of this time and the providedLocalDate
.static java.time.LocalDate
leftShift(java.time.YearMonth self, int dayOfMonth)
Returns aLocalDate
of this year/month and the given day of the month.static java.time.YearMonth
leftShift(java.time.Year self, java.time.Month month)
Returns aYearMonth
of this year and the providedMonth
.static java.time.LocalDate
leftShift(java.time.Year self, java.time.MonthDay monthDay)
Returns aLocalDate
of this year on the givenMonthDay
.static java.time.ZonedDateTime
leftShift(java.time.ZoneId self, java.time.LocalDateTime dateTime)
Returns aZonedDateTime
of this zone and the givenLocalDateTime
.static java.time.OffsetDateTime
leftShift(java.time.ZoneOffset self, java.time.LocalDateTime dateTime)
Returns anOffsetDateTime
of this offset and the providedLocalDateTime
.static java.time.OffsetTime
leftShift(java.time.ZoneOffset self, java.time.LocalTime time)
Returns anOffsetDateTime
of this offset and the providedLocalTime
.static java.time.DayOfWeek
minus(java.time.DayOfWeek self, int days)
Returns theDayOfWeek
that isdays
many days before this day of the week.static java.time.Duration
minus(java.time.Duration self, long seconds)
Returns aDuration
that isseconds
seconds shorter that this duration.static java.time.Instant
minus(java.time.Instant self, long seconds)
Returns anInstant
that isseconds
seconds before this instant.static java.time.LocalDate
minus(java.time.LocalDate self, long days)
Returns aLocalDate
that isdays
days before this date.static long
minus(java.time.LocalDate self, java.time.LocalDate other)
Calculates the number of days between two datesstatic java.time.LocalDateTime
minus(java.time.LocalDateTime self, long seconds)
Returns aLocalDateTime
that isseconds
seconds before this date/time.static java.time.LocalTime
minus(java.time.LocalTime self, long seconds)
Returns aLocalTime
that isseconds
seconds before this time.static java.time.Month
minus(java.time.Month self, int months)
Returns theMonth
that ismonths
months before this month.static java.time.OffsetDateTime
minus(java.time.OffsetDateTime self, long seconds)
Returns anOffsetDateTime
that isseconds
seconds before this date/time.static java.time.OffsetTime
minus(java.time.OffsetTime self, long seconds)
Returns anOffsetTime
that isseconds
seconds before this time.static java.time.Period
minus(java.time.Period self, long days)
Returns aPeriod
that isdays
days shorter than this period.static java.time.YearMonth
minus(java.time.YearMonth self, long months)
Returns aYearMonth
that ismonths
months before this year/month.static java.time.Year
minus(java.time.Year self, long years)
Returns aYear
that isyears
years before this year.static java.time.ZonedDateTime
minus(java.time.ZonedDateTime self, long seconds)
Returns aZonedDateTime
that isseconds
seconds before this date/time.static java.time.Duration
multiply(java.time.Duration self, long scalar)
Supports the multiplication operator; equivalent to calling theDuration.multipliedBy(long)
method.static java.time.Period
multiply(java.time.Period self, int scalar)
Supports the multiply operator; equivalent to calling thePeriod.multipliedBy(int)
method.static java.time.Duration
negative(java.time.Duration self)
Supports the unary minus operator; equivalent to calling theDuration.negated()
method.static java.time.Period
negative(java.time.Period self)
Supports the unary minus operator; equivalent to calling thePeriod.negated()
method.static java.time.Duration
next(java.time.Duration self)
Returns aDuration
that is one second longer than this duration.static java.time.Instant
next(java.time.Instant self)
Returns anInstant
that is one second after this instant.static java.time.LocalDate
next(java.time.LocalDate self)
Returns aLocalDate
one day after this date.static java.time.LocalDateTime
next(java.time.LocalDateTime self)
Returns aLocalDateTime
that is one second after this date/time.static java.time.LocalTime
next(java.time.LocalTime self)
Returns aLocalTime
that is one second after this time.static java.time.OffsetDateTime
next(java.time.OffsetDateTime self)
Returns anOffsetDateTime
one second after this date/time.static java.time.OffsetTime
next(java.time.OffsetTime self)
Returns anOffsetTime
that is one second after this time.static java.time.Period
next(java.time.Period self)
Returns aPeriod
that is one day longer than this period.static java.time.Year
next(java.time.Year self)
Returns aYear
after this year.static java.time.YearMonth
next(java.time.YearMonth self)
Returns aYearMonth
that is the month after this year/month.static java.time.ZonedDateTime
next(java.time.ZonedDateTime self)
Returns aZonedDateTime
that is one second after this date/time.static java.time.DayOfWeek
plus(java.time.DayOfWeek self, int days)
Returns theDayOfWeek
that isdays
many days after this day of the week.static java.time.Duration
plus(java.time.Duration self, long seconds)
Returns aDuration
that isseconds
seconds longer than this duration.static java.time.Instant
plus(java.time.Instant self, long seconds)
Returns anInstant
that isseconds
seconds after this instant.static java.time.LocalDate
plus(java.time.LocalDate self, long days)
Returns aLocalDate
that isdays
days after this date.static java.time.LocalDateTime
plus(java.time.LocalDateTime self, long seconds)
Returns aLocalDateTime
that isseconds
seconds after this date/time.static java.time.LocalTime
plus(java.time.LocalTime self, long seconds)
Returns aLocalTime
that isseconds
seconds after this time.static java.time.Month
plus(java.time.Month self, int months)
Returns theMonth
that ismonths
months after this month.static java.time.OffsetDateTime
plus(java.time.OffsetDateTime self, long seconds)
Returns anOffsetDateTime
that isseconds
seconds after this date/time.static java.time.OffsetTime
plus(java.time.OffsetTime self, long seconds)
Returns anOffsetTime
that isseconds
seconds after this time.static java.time.Period
plus(java.time.Period self, long days)
Returns aPeriod
that isdays
days longer than this period.static java.time.YearMonth
plus(java.time.YearMonth self, long months)
Returns aYearMonth
that ismonths
months after this year/month.static java.time.Year
plus(java.time.Year self, long years)
Returns aYear
that isyears
years after this year.static java.time.ZonedDateTime
plus(java.time.ZonedDateTime self, long seconds)
Returns aZonedDateTime
that isseconds
seconds after this date/time.static java.time.Duration
positive(java.time.Duration self)
Supports the unary plus operator; equivalent to calling theDuration.abs()
method.static java.time.Period
positive(java.time.Period self)
Supports the unary plus operator; returns aPeriod
with all unit values positive.static java.time.Duration
previous(java.time.Duration self)
Returns aDuration
that is one second shorter than this duration.static java.time.Instant
previous(java.time.Instant self)
Returns anInstant
that one second before this instant.static java.time.LocalDate
previous(java.time.LocalDate self)
Returns aLocalDate
one day before this date.static java.time.LocalDateTime
previous(java.time.LocalDateTime self)
Returns aLocalDateTime
that is one second before this date/time.static java.time.LocalTime
previous(java.time.LocalTime self)
Returns aLocalTime
that is one second before this time.static java.time.OffsetDateTime
previous(java.time.OffsetDateTime self)
Returns anOffsetDateTime
one second before this date/time.static java.time.OffsetTime
previous(java.time.OffsetTime self)
Returns anOffsetTime
that is one second before this time.static java.time.Period
previous(java.time.Period self)
Returns aPeriod
that is one day shorter than this period.static java.time.Year
previous(java.time.Year self)
Returns aYear
before this year.static java.time.YearMonth
previous(java.time.YearMonth self)
Returns aYearMonth
that is the month before this year/month.static java.time.ZonedDateTime
previous(java.time.ZonedDateTime self)
Returns aZonedDateTime
that is one second before this date/time.static java.time.Period
rightShift(java.time.LocalDate self, java.time.LocalDate other)
Returns aPeriod
equivalent to the time between this date (inclusive) and the providedLocalDate
(exclusive).static java.time.temporal.TemporalAmount
rightShift(java.time.temporal.Temporal self, java.time.temporal.Temporal other)
Returns aDuration
orPeriod
between this (inclusive) and theother
Temporal
(exclusive).static java.time.Period
rightShift(java.time.YearMonth self, java.time.YearMonth other)
Returns aPeriod
of time between the first day of this year/month (inclusive) and the givenYearMonth
(exclusive).static java.time.Period
rightShift(java.time.Year self, java.time.Year year)
Returns aPeriod
between the first day of this year (inclusive) and the first day of the providedYear
(exclusive).static java.util.Calendar
toCalendar(java.time.Instant self)
Returns a generally equivalentCalendar
in the GMT time zone, truncated to milliseconds.static java.util.Calendar
toCalendar(java.time.LocalDate self)
Returns an equivalent instance ofCalendar
.static java.util.Calendar
toCalendar(java.time.LocalDateTime self)
Returns a generally equivalent instance ofCalendar
.static java.util.Calendar
toCalendar(java.time.LocalTime self)
Returns a generally equivalent instance ofCalendar
.static java.util.Calendar
toCalendar(java.time.OffsetDateTime self)
Returns a generally equivalent instance ofCalendar
.static java.util.Calendar
toCalendar(java.time.OffsetTime self)
Returns a generally equivalent instance ofCalendar
.static java.util.Calendar
toCalendar(java.time.ZonedDateTime self)
Returns a generally equivalent instance ofCalendar
.static java.util.Date
toDate(java.time.Instant self)
Returns a generally equivalentDate
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 ofDate
.static java.util.Date
toDate(java.time.LocalDateTime self)
Returns a generally equivalent instance ofDate
.static java.util.Date
toDate(java.time.LocalTime self)
Returns a generally equivalent instance ofDate
.static java.util.Date
toDate(java.time.OffsetDateTime self)
Returns a generally equivalent instance ofDate
.static java.util.Date
toDate(java.time.OffsetTime self)
Returns a generally equivalent instance ofDate
.static java.util.Date
toDate(java.time.ZonedDateTime self)
Returns a generally equivalent instance ofDate
.static java.time.DayOfWeek
toDayOfWeek(java.util.Calendar self)
Converts the Calendar to a correspondingDayOfWeek
.static java.time.DayOfWeek
toDayOfWeek(java.util.Date self)
Converts the Date to a correspondingDayOfWeek
.static java.time.Instant
toInstant(java.util.Calendar self)
Convenience method for converting a Calendar to a correspondingInstant
.static java.time.LocalDate
toLocalDate(java.util.Date self)
Converts the Date to a correspondingLocalDate
.static java.time.LocalDateTime
toLocalDateTime(java.util.Calendar self)
Converts the Calendar to a correspondingLocalDateTime
.static java.time.LocalDateTime
toLocalDateTime(java.util.Date self)
Converts the Date to a correspondingLocalDateTime
.static java.time.LocalTime
toLocalTime(java.util.Calendar self)
Converts the Calendar to a correspondingLocalTime
.static java.time.LocalTime
toLocalTime(java.util.Date self)
Converts the Date to a correspondingLocalTime
.static java.time.Month
toMonth(java.util.Calendar self)
Converts the Calendar to a correspondingMonth
.static java.time.Month
toMonth(java.util.Date self)
Converts the Date to a correspondingMonth
.static java.time.MonthDay
toMonthDay(java.util.Calendar self)
Converts the Calendar to a correspondingMonthDay
.static java.time.MonthDay
toMonthDay(java.util.Date self)
Converts the Date to a correspondingMonthDay
.static java.time.OffsetDateTime
toOffsetDateTime(java.util.Calendar self)
Converts the Calendar to a correspondingOffsetDateTime
.static java.time.OffsetDateTime
toOffsetDateTime(java.util.Date self)
Converts the Date to a correspondingOffsetDateTime
.static java.time.OffsetTime
toOffsetTime(java.util.Calendar self)
Converts the Calendar to a correspondingOffsetTime
.static java.time.OffsetTime
toOffsetTime(java.util.Date self)
Converts the Date to a correspondingOffsetTime
.static java.util.TimeZone
toTimeZone(java.time.ZoneId self)
Returns aTimeZone
equivalent to this zone.static java.util.TimeZone
toTimeZone(java.time.ZoneOffset self)
Returns a generally equivalentTimeZone
.static java.time.Year
toYear(java.util.Calendar self)
Converts the Calendar to a correspondingYear
.static java.time.Year
toYear(java.util.Date self)
Converts the Date to a correspondingYear
.static java.time.YearMonth
toYearMonth(java.util.Calendar self)
Converts the Calendar to a correspondingYearMonth
.static java.time.YearMonth
toYearMonth(java.util.Date self)
Converts the Date to a correspondingYearMonth
.static java.time.ZonedDateTime
toZonedDateTime(java.util.Calendar self)
Converts the Calendar to a correspondingZonedDateTime
.static java.time.ZonedDateTime
toZonedDateTime(java.util.Date self)
Converts the Date to a correspondingZonedDateTime
.static java.time.ZoneOffset
toZoneOffset(java.util.TimeZone self)
Converts the TimeZone to a correspondingZoneOffset
.static java.time.ZoneOffset
toZoneOffset(java.util.TimeZone self, java.time.Instant instant)
Converts this TimeZone to a correspondingZoneOffset
.static void
upto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, Closure closure)
Iterates from this to theto
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 theto
Temporal
, inclusive, incrementing by oneunit
each iteration, calling the closure once per iteration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
upto
public static void upto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, Closure closure)Iterates from this to theto
Temporal
, inclusive, incrementing by one unit each iteration, calling the closure once per iteration. The closure may accept a singleTemporal
argument.The particular unit incremented by depends on the specific sub-type of
Temporal
. Most sub-types use a unit ofChronoUnit.SECONDS
except forChronoLocalDate
and its sub-types useChronoUnit.DAYS
.YearMonth
usesChronoUnit.MONTHS
.Year
usesChronoUnit.YEARS
.
- Parameters:
from
- the starting Temporalto
- the ending Temporalclosure
- the zero or one-argument closure to call- Throws:
GroovyRuntimeException
- if this value is later thanto
GroovyRuntimeException
- ifto
is a different type than this- Since:
- 2.5.0
-
upto
public static void upto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, java.time.temporal.TemporalUnit unit, Closure closure)Iterates from this to theto
Temporal
, inclusive, incrementing by oneunit
each iteration, calling the closure once per iteration. The closure may accept a singleTemporal
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 theto
value.- Parameters:
from
- the starting Temporalto
- the ending Temporalunit
- the TemporalUnit to increment byclosure
- the zero or one-argument closure to call- Throws:
GroovyRuntimeException
- if this value is later thanto
GroovyRuntimeException
- ifto
is a different type than this- Since:
- 2.5.0
-
downto
public static void downto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, Closure closure)Iterates from this to theto
Temporal
, inclusive, decrementing by one unit each iteration, calling the closure once per iteration. The closure may accept a singleTemporal
argument.The particular unit decremented by depends on the specific sub-type of
Temporal
. Most sub-types use a unit ofChronoUnit.SECONDS
except forChronoLocalDate
and its sub-types useChronoUnit.DAYS
.YearMonth
usesChronoUnit.MONTHS
.Year
usesChronoUnit.YEARS
.
- Parameters:
from
- the starting Temporalto
- the ending Temporalclosure
- the zero or one-argument closure to call- Throws:
GroovyRuntimeException
- if this value is earlier thanto
GroovyRuntimeException
- ifto
is a different type than this- Since:
- 2.5.0
-
downto
public static void downto(java.time.temporal.Temporal from, java.time.temporal.Temporal to, java.time.temporal.TemporalUnit unit, Closure closure)Iterates from this to theto
Temporal
, inclusive, decrementing by oneunit
each iteration, calling the closure once per iteration. The closure may accept a singleTemporal
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 theto
value.- Parameters:
from
- the starting Temporalto
- the ending Temporalunit
- the TemporalUnit to increment byclosure
- the zero or one-argument closure to call- Throws:
GroovyRuntimeException
- if this value is earlier thanto
GroovyRuntimeException
- ifto
is a different type than this- Since:
- 2.5.0
-
rightShift
public static java.time.temporal.TemporalAmount rightShift(java.time.temporal.Temporal self, java.time.temporal.Temporal other)Returns aDuration
orPeriod
between this (inclusive) and theother
Temporal
(exclusive).A Period will be returned for types
Year
,YearMonth
, andChronoLocalDate
; otherwise, a Duration will be returned.Note: if the Temporal is a ChronoLocalDate but not a
LocalDate
, a generalChronoPeriod
will be returned as per the return type of the methodChronoLocalDate.until(ChronoLocalDate)
.- Parameters:
self
- a Temporalother
- another Temporal of the same type- Returns:
- an TemporalAmount between the two Temporals
- Since:
- 2.5.0
-
getAt
public static long getAt(java.time.temporal.TemporalAccessor self, java.time.temporal.TemporalField field)Supports the getAt operator; equivalent to calling theTemporalAccessor.getLong(java.time.temporal.TemporalField)
method.- Parameters:
self
- a TemporalAccessorfield
- a non-null TemporalField- Returns:
- the value for the field
- Throws:
java.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 occurs- Since:
- 2.5.0
-
getAt
public static long getAt(java.time.temporal.TemporalAmount self, java.time.temporal.TemporalUnit unit)Supports the getAt operator; equivalent to calling theTemporalAmount.get(TemporalUnit)
method.- Parameters:
self
- a TemporalAmountunit
- a non-null TemporalUnit- Returns:
- the value for the field
- Throws:
java.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 occurs- Since:
- 2.5.0
-
plus
public static java.time.Duration plus(java.time.Duration self, long seconds)Returns aDuration
that isseconds
seconds longer than this duration.- Parameters:
self
- a Durationseconds
- the number of seconds to add- Returns:
- a Duration
- Since:
- 2.5.0
-
minus
public static java.time.Duration minus(java.time.Duration self, long seconds)Returns aDuration
that isseconds
seconds shorter that this duration.- Parameters:
self
- a Durationseconds
- the number of seconds to subtract- Returns:
- a Duration
- Since:
- 2.5.0
-
next
public static java.time.Duration next(java.time.Duration self)Returns aDuration
that is one second longer than this duration.- Parameters:
self
- a Duration- Returns:
- a Duration
- Since:
- 2.5.0
-
previous
public static java.time.Duration previous(java.time.Duration self)Returns aDuration
that is one second shorter than this duration.- Parameters:
self
- a Duration- Returns:
- a Duration
- Since:
- 2.5.0
-
negative
public static java.time.Duration negative(java.time.Duration self)Supports the unary minus operator; equivalent to calling theDuration.negated()
method.- Parameters:
self
- a Duration- Returns:
- a Duration
- Since:
- 2.5.0
-
positive
public static java.time.Duration positive(java.time.Duration self)Supports the unary plus operator; equivalent to calling theDuration.abs()
method.- Parameters:
self
- a Duration- Returns:
- a Duration
- Since:
- 2.5.0
-
multiply
public static java.time.Duration multiply(java.time.Duration self, long scalar)Supports the multiplication operator; equivalent to calling theDuration.multipliedBy(long)
method.- Parameters:
self
- a Durationscalar
- the value to multiply by- Returns:
- a Duration
- Since:
- 2.5.0
-
div
public static java.time.Duration div(java.time.Duration self, long scalar)Supports the division operator; equivalent to calling theDuration.dividedBy(long)
method.- Parameters:
self
- a Durationscalar
- the value to divide by- Returns:
- a Duration
- Since:
- 2.5.0
-
isPositive
public static boolean isPositive(java.time.Duration self)Returns true if this duration is positive, excluding zero.- Parameters:
self
- a Duration- Returns:
- true if positive
- Since:
- 2.5.0
-
isNonnegative
public static boolean isNonnegative(java.time.Duration self)Returns true if this duration is zero or positive.- Parameters:
self
- a Duration- Returns:
- true if nonnegative
- Since:
- 2.5.0
-
isNonpositive
public static boolean isNonpositive(java.time.Duration self)Returns true if this duration is zero or negative.- Parameters:
self
- a Duration- Returns:
- true if nonpositive
- Since:
- 2.5.0
-
plus
public static java.time.Instant plus(java.time.Instant self, long seconds)Returns anInstant
that isseconds
seconds after this instant.- Parameters:
self
- an Instantseconds
- the number of seconds to add- Returns:
- an Instant
- Since:
- 2.5.0
-
minus
public static java.time.Instant minus(java.time.Instant self, long seconds)Returns anInstant
that isseconds
seconds before this instant.- Parameters:
self
- an Instantseconds
- the number of seconds to subtract- Returns:
- an Instant
- Since:
- 2.5.0
-
next
public static java.time.Instant next(java.time.Instant self)Returns anInstant
that is one second after this instant.- Parameters:
self
- an Instant- Returns:
- an Instant one second ahead
- Since:
- 2.5.0
-
previous
public static java.time.Instant previous(java.time.Instant self)Returns anInstant
that one second before this instant.- Parameters:
self
- an Instant- Returns:
- an Instant one second behind
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.Instant self)Returns a generally equivalentDate
according the number of milliseconds since the epoch, adjusted into the system default time zone.- Parameters:
self
- an Instant- Returns:
- a Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.Instant self)Returns a generally equivalentCalendar
in the GMT time zone, truncated to milliseconds.- Parameters:
self
- an Instant- Returns:
- a Calendar
- Since:
- 2.5.0
-
format
public static java.lang.String format(java.time.LocalDate self, java.lang.String pattern)Formats this date with the providedDateTimeFormatter
pattern.- Parameters:
self
- a LocalDatepattern
- the formatting pattern- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
format
public static java.lang.String format(java.time.LocalDate self, java.time.format.FormatStyle dateStyle)Formats this date in the provided, localizedFormatStyle
.- Parameters:
self
- a LocalDatedateStyle
- the FormatStyle- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateString
public static java.lang.String getDateString(java.time.LocalDate self)Formats this date with theDateTimeFormatter.ISO_LOCAL_DATE
formatter.- Parameters:
self
- a LocalDate- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
plus
public static java.time.LocalDate plus(java.time.LocalDate self, long days)Returns aLocalDate
that isdays
days after this date.- Parameters:
self
- a LocalDatedays
- the number of days to add- Returns:
- a LocalDate
- Since:
- 2.5.0
-
minus
public static java.time.LocalDate minus(java.time.LocalDate self, long days)Returns aLocalDate
that isdays
days before this date.- Parameters:
self
- a LocalDatedays
- the number of days to subtract- Returns:
- a LocalDate
- Since:
- 2.5.0
-
minus
public static long minus(java.time.LocalDate self, java.time.LocalDate other)Calculates the number of days between two dates- Parameters:
self
- a LocalDateother
- the other LocalDate- Returns:
- the number of days
- Since:
- 3.0.0
-
next
public static java.time.LocalDate next(java.time.LocalDate self)Returns aLocalDate
one day after this date.- Parameters:
self
- a LocalDate- Returns:
- the next day
- Since:
- 2.5.0
-
previous
public static java.time.LocalDate previous(java.time.LocalDate self)Returns aLocalDate
one day before this date.- Parameters:
self
- a LocalDate- Returns:
- the previous day
- Since:
- 2.5.0
-
rightShift
public static java.time.Period rightShift(java.time.LocalDate self, java.time.LocalDate other)Returns aPeriod
equivalent to the time between this date (inclusive) and the providedLocalDate
(exclusive).- Parameters:
self
- a LocalDateother
- another LocalDate- Returns:
- a Period representing the time between the two LocalDates
- Since:
- 2.5.0
-
leftShift
public static java.time.LocalDateTime leftShift(java.time.LocalDate self, java.time.LocalTime time)Returns aLocalDateTime
from this date and the providedLocalTime
.- Parameters:
self
- a LocalDatetime
- a LocalTime- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
leftShift
public static java.time.OffsetDateTime leftShift(java.time.LocalDate self, java.time.OffsetTime time)Returns aOffsetDateTime
from this date and the providedOffsetTime
.- Parameters:
self
- a LocalDatetime
- an OffsetTime- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.LocalDate self)Returns an equivalent instance ofDate
. The time portion of the returned date is cleared.- Parameters:
self
- a LocalDate- Returns:
- a java.util.Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.LocalDate self)Returns an equivalent instance ofCalendar
. The time portion of the returned calendar is cleared and the time zone is the current system default.- Parameters:
self
- a LocalDate- Returns:
- a java.util.Calendar
- Since:
- 2.5.0
-
format
public static java.lang.String format(java.time.LocalDateTime self, java.lang.String pattern)Formats this date/time with the providedDateTimeFormatter
pattern.- Parameters:
self
- a LocalDateTimepattern
- the formatting pattern- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
format
public static java.lang.String format(java.time.LocalDateTime self, java.time.format.FormatStyle dateTimeStyle)Formats this date/time in the provided, localizedFormatStyle
.- Parameters:
self
- a LocalDateTimedateTimeStyle
- the FormatStyle- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateTimeString
public static java.lang.String getDateTimeString(java.time.LocalDateTime self)Formats this date/time with theDateTimeFormatter.ISO_LOCAL_DATE_TIME
formatter.- Parameters:
self
- a LocalDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateString
public static java.lang.String getDateString(java.time.LocalDateTime self)Formats this date/time with theDateTimeFormatter.ISO_LOCAL_DATE
formatter.- Parameters:
self
- a LocalDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getTimeString
public static java.lang.String getTimeString(java.time.LocalDateTime self)Formats this date/time with theDateTimeFormatter.ISO_LOCAL_TIME
formatter.- Parameters:
self
- a LocalDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
clearTime
public static java.time.LocalDateTime clearTime(java.time.LocalDateTime self)Returns aLocalDateTime
with the time portion cleared.- Parameters:
self
- a LocalDateTime- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
plus
public static java.time.LocalDateTime plus(java.time.LocalDateTime self, long seconds)Returns aLocalDateTime
that isseconds
seconds after this date/time.- Parameters:
self
- a LocalDateTimeseconds
- the number of seconds to add- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
minus
public static java.time.LocalDateTime minus(java.time.LocalDateTime self, long seconds)Returns aLocalDateTime
that isseconds
seconds before this date/time.- Parameters:
self
- a LocalDateTimeseconds
- the number of seconds to subtract- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
next
public static java.time.LocalDateTime next(java.time.LocalDateTime self)Returns aLocalDateTime
that is one second after this date/time.- Parameters:
self
- a LocalDateTime- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
previous
public static java.time.LocalDateTime previous(java.time.LocalDateTime self)Returns aLocalDateTime
that is one second before this date/time.- Parameters:
self
- a LocalDateTime- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
leftShift
public static java.time.OffsetDateTime leftShift(java.time.LocalDateTime self, java.time.ZoneOffset offset)Returns anOffsetDateTime
of this date/time and the providedZoneOffset
.- Parameters:
self
- a LocalDateTimeoffset
- a ZoneOffset- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
leftShift
public static java.time.ZonedDateTime leftShift(java.time.LocalDateTime self, java.time.ZoneId zone)Returns aOffsetDateTime
of this date/time and the providedZoneId
.- Parameters:
self
- a LocalDateTimezone
- a ZoneId- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.LocalDateTime self)Returns a generally equivalent instance ofDate
. The time value of the returned date is truncated to milliseconds.- Parameters:
self
- a LocalDateTime- Returns:
- a java.util.Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.LocalDateTime self)Returns a generally equivalent instance ofCalendar
. The time value of the returned calendar is truncated to milliseconds and the time zone is the current system default.- Parameters:
self
- a LocalDateTime- Returns:
- a java.util.Calendar
- Since:
- 2.5.0
-
format
public static java.lang.String format(java.time.LocalTime self, java.lang.String pattern)Formats this time with the providedDateTimeFormatter
pattern.- Parameters:
self
- a LocalDateTimepattern
- the formatting pattern- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
format
public static java.lang.String format(java.time.LocalTime self, java.time.format.FormatStyle timeStyle)Formats this time in the provided, localizedFormatStyle
.- Parameters:
self
- a LocalTimetimeStyle
- the FormatStyle- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getTimeString
public static java.lang.String getTimeString(java.time.LocalTime self)Formats this time with theDateTimeFormatter.ISO_LOCAL_TIME
formatter.- Parameters:
self
- a LocalTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
plus
public static java.time.LocalTime plus(java.time.LocalTime self, long seconds)Returns aLocalTime
that isseconds
seconds after this time.- Parameters:
self
- a LocalTimeseconds
- the number of seconds to add- Returns:
- a LocalTime
- Since:
- 2.5.0
-
minus
public static java.time.LocalTime minus(java.time.LocalTime self, long seconds)Returns aLocalTime
that isseconds
seconds before this time.- Parameters:
self
- a LocalTimeseconds
- the number of seconds to subtract- Returns:
- a LocalTime
- Since:
- 2.5.0
-
next
public static java.time.LocalTime next(java.time.LocalTime self)Returns aLocalTime
that is one second after this time.- Parameters:
self
- a LocalTime- Returns:
- a LocalTime
- Since:
- 2.5.0
-
previous
public static java.time.LocalTime previous(java.time.LocalTime self)Returns aLocalTime
that is one second before this time.- Parameters:
self
- a LocalTime- Returns:
- a LocalTime
- Since:
- 2.5.0
-
leftShift
public static java.time.LocalDateTime leftShift(java.time.LocalTime self, java.time.LocalDate date)Returns aLocalDateTime
of this time and the providedLocalDate
.- Parameters:
self
- a LocalTimedate
- a LocalDate- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
leftShift
public static java.time.OffsetTime leftShift(java.time.LocalTime self, java.time.ZoneOffset offset)Returns anOffsetTime
of this time and the providedZoneOffset
.- Parameters:
self
- a LocalTimeoffset
- a ZoneOffset- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.LocalTime self)Returns a generally equivalent instance ofDate
. The day-month-year value of the returned date is today and the time is truncated to milliseconds.- Parameters:
self
- a LocalTime- Returns:
- a java.util.Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.LocalTime self)Returns a generally equivalent instance ofCalendar
. 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.- Parameters:
self
- a LocalTime- Returns:
- a java.util.Calendar
- Since:
- 2.5.0
-
leftShift
public static java.time.LocalDate leftShift(java.time.MonthDay self, int year)Returns aLocalDate
of this month/day and the provided year.- Parameters:
self
- a MonthDayyear
- a year- Returns:
- a LocalDate
- Since:
- 2.5.0
-
leftShift
public static java.time.LocalDate leftShift(java.time.MonthDay self, java.time.Year year)Returns aLocalDate
of this month/day and the providedYear
.- Parameters:
self
- a MonthDayyear
- a Year- Returns:
- a LocalDate
- Since:
- 2.5.0
-
format
public static java.lang.String format(java.time.OffsetDateTime self, java.lang.String pattern)Formats this date/time with the providedDateTimeFormatter
pattern.- Parameters:
self
- an OffsetDateTimepattern
- the formatting pattern- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
format
public static java.lang.String format(java.time.OffsetDateTime self, java.time.format.FormatStyle dateTimeStyle)Formats this date/time in the provided, localizedFormatStyle
.- Parameters:
self
- an OffsetDateTimedateTimeStyle
- the FormatStyle- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateTimeString
public static java.lang.String getDateTimeString(java.time.OffsetDateTime self)Formats this date/time with theDateTimeFormatter.ISO_OFFSET_DATE_TIME
formatter.- Parameters:
self
- an OffsetDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateString
public static java.lang.String getDateString(java.time.OffsetDateTime self)Formats this date/time with theDateTimeFormatter.ISO_OFFSET_DATE
formatter.- Parameters:
self
- an OffsetDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getTimeString
public static java.lang.String getTimeString(java.time.OffsetDateTime self)Formats this date/time with theDateTimeFormatter.ISO_OFFSET_TIME
formatter.- Parameters:
self
- an OffsetDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
clearTime
public static java.time.OffsetDateTime clearTime(java.time.OffsetDateTime self)Returns anOffsetDateTime
with the time portion cleared.- Parameters:
self
- an OffsetDateTime- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
plus
public static java.time.OffsetDateTime plus(java.time.OffsetDateTime self, long seconds)Returns anOffsetDateTime
that isseconds
seconds after this date/time.- Parameters:
self
- an OffsetDateTimeseconds
- the number of seconds to add- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
minus
public static java.time.OffsetDateTime minus(java.time.OffsetDateTime self, long seconds)Returns anOffsetDateTime
that isseconds
seconds before this date/time.- Parameters:
self
- an OffsetDateTimeseconds
- the number of seconds to subtract- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
next
public static java.time.OffsetDateTime next(java.time.OffsetDateTime self)Returns anOffsetDateTime
one second after this date/time.- Parameters:
self
- an OffsetDateTime- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
previous
public static java.time.OffsetDateTime previous(java.time.OffsetDateTime self)Returns anOffsetDateTime
one second before this date/time.- Parameters:
self
- an OffsetDateTime- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.OffsetDateTime self)Returns a generally equivalent instance ofDate
. The time value of the returned date is truncated to milliseconds and will be adjusted to the current system default time zone.- Parameters:
self
- an OffsetDateTime- Returns:
- a java.util.Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.OffsetDateTime self)Returns a generally equivalent instance ofCalendar
. The time value of the returned calendar is truncated to milliseconds and the time zone is based on the offset of this date/time.- Parameters:
self
- an OffsetDateTime- Returns:
- a java.util.Calendar
- Since:
- 2.5.0
-
format
public static java.lang.String format(java.time.OffsetTime self, java.lang.String pattern)Formats this time with the providedDateTimeFormatter
pattern.- Parameters:
self
- an OffsetTimepattern
- the formatting pattern- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
format
public static java.lang.String format(java.time.OffsetTime self, java.time.format.FormatStyle timeStyle)Formats this time in the provided, localizedFormatStyle
.- Parameters:
self
- an OffsetTimetimeStyle
- the FormatStyle- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getTimeString
public static java.lang.String getTimeString(java.time.OffsetTime self)Formats this time with theDateTimeFormatter.ISO_OFFSET_TIME
formatter.- Parameters:
self
- an OffsetTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
plus
public static java.time.OffsetTime plus(java.time.OffsetTime self, long seconds)Returns anOffsetTime
that isseconds
seconds after this time.- Parameters:
self
- an OffsetTimeseconds
- the number of seconds to add- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
minus
public static java.time.OffsetTime minus(java.time.OffsetTime self, long seconds)Returns anOffsetTime
that isseconds
seconds before this time.- Parameters:
self
- an OffsetTimeseconds
- the number of seconds to subtract- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
next
public static java.time.OffsetTime next(java.time.OffsetTime self)Returns anOffsetTime
that is one second after this time.- Parameters:
self
- an OffsetTime- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
previous
public static java.time.OffsetTime previous(java.time.OffsetTime self)Returns anOffsetTime
that is one second before this time.- Parameters:
self
- an OffsetTime- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
leftShift
public static java.time.OffsetDateTime leftShift(java.time.OffsetTime self, java.time.LocalDate date)Returns anOffsetDateTime
of this time and the providedLocalDate
.- Parameters:
self
- an OffsetTimedate
- a LocalDate- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.OffsetTime self)Returns a generally equivalent instance ofDate
. The time value of the returned date is truncated to milliseconds and will be adjusted to the current system default time zone.- Parameters:
self
- an OffsetTime- Returns:
- a java.util.Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.OffsetTime self)Returns a generally equivalent instance ofCalendar
. 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.- Parameters:
self
- an OffsetTime- Returns:
- a java.util.Calendar
- Since:
- 2.5.0
-
plus
public static java.time.Period plus(java.time.Period self, long days)Returns aPeriod
that isdays
days longer than this period. No normalization is performed.- Parameters:
self
- a Perioddays
- the number of days to increase this Period by- Returns:
- a Period
- Since:
- 2.5.0
-
minus
public static java.time.Period minus(java.time.Period self, long days)Returns aPeriod
that isdays
days shorter than this period. No normalization is performed.- Parameters:
self
- a Perioddays
- the number of days to decrease this Period by- Returns:
- a Period
- Since:
- 2.5.0
-
next
public static java.time.Period next(java.time.Period self)Returns aPeriod
that is one day longer than this period. No normalization is performed.- Parameters:
self
- a Period- Returns:
- a Period one day longer in length
- Since:
- 2.5.0
-
previous
public static java.time.Period previous(java.time.Period self)Returns aPeriod
that is one day shorter than this period. No normalization is performed.- Parameters:
self
- a Period- Returns:
- a Period one day shorter in length
- Since:
- 2.5.0
-
negative
public static java.time.Period negative(java.time.Period self)Supports the unary minus operator; equivalent to calling thePeriod.negated()
method.- Parameters:
self
- a Period- Returns:
- a negated Period
- Since:
- 2.5.0
-
positive
public static java.time.Period positive(java.time.Period self)Supports the unary plus operator; returns aPeriod
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.- Parameters:
self
- a Period- Returns:
- a positive Period
- Since:
- 2.5.0
-
multiply
public static java.time.Period multiply(java.time.Period self, int scalar)Supports the multiply operator; equivalent to calling thePeriod.multipliedBy(int)
method.- Parameters:
self
- a Periodscalar
- a scalar to multiply each unit by- Returns:
- a Period
- Since:
- 2.5.0
-
isPositive
public static boolean isPositive(java.time.chrono.ChronoPeriod self)Returns true if this period is positive, excluding zero.- Parameters:
self
- a ChronoPeriod- Returns:
- true if positive
- Since:
- 2.5.0
-
isNonnegative
public static boolean isNonnegative(java.time.chrono.ChronoPeriod self)Returns true if this period is zero or positive.- Parameters:
self
- a ChronoPeriod- Returns:
- true if nonnegative
- Since:
- 2.5.0
-
isNonpositive
public static boolean isNonpositive(java.time.chrono.ChronoPeriod self)Returns true if this period is zero or negative.- Parameters:
self
- a ChronoPeriod- Returns:
- true if nonpositive
- Since:
- 2.5.0
-
plus
public static java.time.Year plus(java.time.Year self, long years)Returns aYear
that isyears
years after this year.- Parameters:
self
- a Yearyears
- the number of years to add- Returns:
- a Year
- Since:
- 2.5.0
-
minus
public static java.time.Year minus(java.time.Year self, long years)Returns aYear
that isyears
years before this year.- Parameters:
self
- a Yearyears
- the number of years to subtract- Returns:
- a Year
- Since:
- 2.5.0
-
next
public static java.time.Year next(java.time.Year self)Returns aYear
after this year.- Parameters:
self
- a Year- Returns:
- the next Year
- Since:
- 2.5.0
-
previous
public static java.time.Year previous(java.time.Year self)Returns aYear
before this year.- Parameters:
self
- a Year- Returns:
- the previous Year
- Since:
- 2.5.0
-
rightShift
public static java.time.Period rightShift(java.time.Year self, java.time.Year year)Returns aPeriod
between the first day of this year (inclusive) and the first day of the providedYear
(exclusive).- Parameters:
self
- a Yearyear
- another Year- Returns:
- a Period between the Years
- Since:
- 2.5.0
-
leftShift
public static java.time.YearMonth leftShift(java.time.Year self, java.time.Month month)Returns aYearMonth
of this year and the providedMonth
.- Parameters:
self
- a Yearmonth
- a Month- Returns:
- a YearMonth
- Since:
- 2.5.0
-
leftShift
public static java.time.LocalDate leftShift(java.time.Year self, java.time.MonthDay monthDay)Returns aLocalDate
of this year on the givenMonthDay
.- Parameters:
self
- a YearmonthDay
- a MonthDay- Returns:
- a LocalDate
- Since:
- 2.5.0
-
getEra
public static int getEra(java.time.Year self)Equivalent to calling theYear.get(java.time.temporal.TemporalField)
method with aChronoField.ERA
argument.Returns the era of the year, which is currently either 0 (BC) or 1 (AD).
- Parameters:
self
- a Year- Returns:
- an int representing the era
- Since:
- 2.5.0
-
getYearOfEra
public static int getYearOfEra(java.time.Year self)Equivalent to calling theYear.get(java.time.temporal.TemporalField)
method with aChronoField.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.
- Parameters:
self
- a Year- Returns:
- the year value of the era
- Since:
- 2.5.0
-
plus
public static java.time.YearMonth plus(java.time.YearMonth self, long months)Returns aYearMonth
that ismonths
months after this year/month.- Parameters:
self
- a YearMonthmonths
- the number of months to add- Returns:
- a Year
- Since:
- 2.5.0
-
minus
public static java.time.YearMonth minus(java.time.YearMonth self, long months)Returns aYearMonth
that ismonths
months before this year/month.- Parameters:
self
- a YearMonthmonths
- the number of months to subtract- Returns:
- a Year
- Since:
- 2.5.0
-
next
public static java.time.YearMonth next(java.time.YearMonth self)Returns aYearMonth
that is the month after this year/month.- Parameters:
self
- a YearMonth- Returns:
- the next YearMonth
- Since:
- 2.5.0
-
previous
public static java.time.YearMonth previous(java.time.YearMonth self)Returns aYearMonth
that is the month before this year/month.- Parameters:
self
- a YearMonth- Returns:
- the previous YearMonth
- Since:
- 2.5.0
-
leftShift
public static java.time.LocalDate leftShift(java.time.YearMonth self, int dayOfMonth)Returns aLocalDate
of this year/month and the given day of the month.- Parameters:
self
- a YearMonthdayOfMonth
- a day of the month- Returns:
- a LocalDate
- Since:
- 2.5.0
-
rightShift
public static java.time.Period rightShift(java.time.YearMonth self, java.time.YearMonth other)Returns aPeriod
of time between the first day of this year/month (inclusive) and the givenYearMonth
(exclusive).- Parameters:
self
- a YearMonthother
- another YearMonth- Returns:
- a Period
- Since:
- 2.5.0
-
format
public static java.lang.String format(java.time.ZonedDateTime self, java.lang.String pattern)Formats this date/time with the providedDateTimeFormatter
pattern.- Parameters:
self
- a ZonedDateTimepattern
- the formatting pattern- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
format
public static java.lang.String format(java.time.ZonedDateTime self, java.time.format.FormatStyle dateTimeStyle)Formats this date/time in the provided, localizedFormatStyle
.- Parameters:
self
- a ZonedDateTimedateTimeStyle
- the FormatStyle- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateTimeString
public static java.lang.String getDateTimeString(java.time.ZonedDateTime self)Formats this date/time with theDateTimeFormatter.ISO_LOCAL_DATE_TIME
formatter and appends the zone's short name, e.g.2018-03-10T14:34:55.144EST
.- Parameters:
self
- a ZonedDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getDateString
public static java.lang.String getDateString(java.time.ZonedDateTime self)Formats this date/time with theDateTimeFormatter.ISO_LOCAL_DATE
formatter and appends the zone's short name, e.g.2018-03-10EST
.- Parameters:
self
- a ZonedDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
getTimeString
public static java.lang.String getTimeString(java.time.ZonedDateTime self)Formats this date/time with theDateTimeFormatter.ISO_LOCAL_TIME
formatter and appends the zone's short name, e.g.14:34:55.144EST
.- Parameters:
self
- a ZonedDateTime- Returns:
- a formatted String
- Since:
- 2.5.0
- See Also:
DateTimeFormatter
-
clearTime
public static java.time.ZonedDateTime clearTime(java.time.ZonedDateTime self)Returns anZonedDateTime
with the time portion cleared.- Parameters:
self
- a ZonedDateTime- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
plus
public static java.time.ZonedDateTime plus(java.time.ZonedDateTime self, long seconds)Returns aZonedDateTime
that isseconds
seconds after this date/time.- Parameters:
self
- an ZonedDateTimeseconds
- the number of seconds to add- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
minus
public static java.time.ZonedDateTime minus(java.time.ZonedDateTime self, long seconds)Returns aZonedDateTime
that isseconds
seconds before this date/time.- Parameters:
self
- a ZonedDateTimeseconds
- the number of seconds to subtract- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
next
public static java.time.ZonedDateTime next(java.time.ZonedDateTime self)Returns aZonedDateTime
that is one second after this date/time.- Parameters:
self
- a ZonedDateTime- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
previous
public static java.time.ZonedDateTime previous(java.time.ZonedDateTime self)Returns aZonedDateTime
that is one second before this date/time.- Parameters:
self
- a ZonedDateTime- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
toDate
public static java.util.Date toDate(java.time.ZonedDateTime self)Returns a generally equivalent instance ofDate
. The time value of the returned date is truncated to milliseconds and will be adjusted to the current system default time zone.- Parameters:
self
- a ZonedDateTime- Returns:
- a java.util.Date
- Since:
- 2.5.0
-
toCalendar
public static java.util.Calendar toCalendar(java.time.ZonedDateTime self)Returns a generally equivalent instance ofCalendar
. The time value of the returned calendar is truncated to milliseconds and the time zone is determined by the zone of this date/time.- Parameters:
self
- an ZonedDateTime- Returns:
- a java.util.Calendar
- Since:
- 2.5.0
-
toTimeZone
public static java.util.TimeZone toTimeZone(java.time.ZoneId self)Returns aTimeZone
equivalent to this zone.- Parameters:
self
- a ZoneId- Returns:
- a TimeZone
- Since:
- 2.5.0
-
getFullName
public static java.lang.String getFullName(java.time.ZoneId self)Returns the name of this zone formatted according to theTextStyle.FULL
text style.- Parameters:
self
- a ZoneId- Returns:
- the full display name of the ZoneId
- Since:
- 2.5.0
-
getFullName
public static java.lang.String getFullName(java.time.ZoneId self, java.util.Locale locale)Returns the name of this zone formatted according to theTextStyle.FULL
text style for the providedLocale
.- Parameters:
self
- a ZoneIdlocale
- a Locale- Returns:
- the full display name of the ZoneId
- Since:
- 2.5.0
-
getShortName
public static java.lang.String getShortName(java.time.ZoneId self)Returns the name of this zone formatted according to theTextStyle.SHORT
text style.- Parameters:
self
- a ZoneId- Returns:
- the short display name of the ZoneId
- Since:
- 2.5.0
-
getShortName
public static java.lang.String getShortName(java.time.ZoneId self, java.util.Locale locale)Returns the name of this zone formatted according to theTextStyle.SHORT
text style for the providedLocale
.- Parameters:
self
- a ZoneIdlocale
- a Locale- Returns:
- the short display name of the ZoneId
- Since:
- 2.5.0
-
getOffset
public static java.time.ZoneOffset getOffset(java.time.ZoneId self)Returns aZoneOffset
for this zone as of now.- Parameters:
self
- a ZoneId- Returns:
- a ZoneOffset
- Since:
- 2.5.0
-
getOffset
public static java.time.ZoneOffset getOffset(java.time.ZoneId self, java.time.Instant instant)Returns aZoneOffset
for this zone as of the providedInstant
.- Parameters:
self
- a ZoneIdinstant
- an Instant- Returns:
- a ZoneOffset
- Since:
- 2.5.0
-
leftShift
public static java.time.ZonedDateTime leftShift(java.time.ZoneId self, java.time.LocalDateTime dateTime)Returns aZonedDateTime
of this zone and the givenLocalDateTime
.- Parameters:
self
- a ZoneId- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
toTimeZone
public static java.util.TimeZone toTimeZone(java.time.ZoneOffset self)Returns a generally equivalentTimeZone
. The offset will be truncated to minutes.- Parameters:
self
- a ZoneOffset- Returns:
- a TimeZone
- Since:
- 2.5.0
-
getHours
public static int getHours(java.time.ZoneOffset self)Returns the hours component of this offset. If the offset's total seconds are negative, a negative value will be returned.- Parameters:
self
- a ZoneOffset- Returns:
- the hours component value
- Since:
- 2.5.0
-
getMinutes
public static int getMinutes(java.time.ZoneOffset self)Returns the minutes component of this offset. If the offset's total seconds are negative, a negative value will be returned.- Parameters:
self
- a ZoneOffset- Returns:
- the minutes component value
- Since:
- 2.5.0
-
getSeconds
public static int getSeconds(java.time.ZoneOffset self)Returns the seconds component of this offset. This is not the same as the total seconds. For example: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.
- Parameters:
self
- a ZoneOffset- Returns:
- the seconds component value
- Since:
- 2.5.0
-
getAt
public static long getAt(java.time.ZoneOffset self, java.time.temporal.TemporalField field)Supports the getAt operator; equivalent to calling theZoneOffset.getLong(java.time.temporal.TemporalField)
method.- Parameters:
self
- a ZoneOffsetfield
- a TemporalField- Returns:
- the ZoneOffset's field value
- Since:
- 2.5.0
-
leftShift
public static java.time.OffsetDateTime leftShift(java.time.ZoneOffset self, java.time.LocalDateTime dateTime)Returns anOffsetDateTime
of this offset and the providedLocalDateTime
.- Parameters:
self
- a ZoneOffsetdateTime
- a LocalDateTime- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
leftShift
public static java.time.OffsetTime leftShift(java.time.ZoneOffset self, java.time.LocalTime time)Returns anOffsetDateTime
of this offset and the providedLocalTime
.- Parameters:
self
- a ZoneOffsettime
- a LocalTime- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
plus
public static java.time.DayOfWeek plus(java.time.DayOfWeek self, int days)Returns theDayOfWeek
that isdays
many days after this day of the week.- Parameters:
self
- a DayOfWeekdays
- the number of days to move forward- Returns:
- the DayOfWeek
- Since:
- 2.5.0
-
minus
public static java.time.DayOfWeek minus(java.time.DayOfWeek self, int days)Returns theDayOfWeek
that isdays
many days before this day of the week.- Parameters:
self
- a DayOfWeekdays
- the number of days to move back- Returns:
- the DayOfWeek
- Since:
- 2.5.0
-
isWeekend
public static boolean isWeekend(java.time.DayOfWeek self)Returnstrue
if this day of the week is a weekend day (Saturday or Sunday).- Parameters:
self
- a DayOfWeek- Returns:
- true if this DayOfWeek is Saturday or Sunday
- Since:
- 2.5.0
-
isWeekday
public static boolean isWeekday(java.time.DayOfWeek self)Returnstrue
if the DayOfWeek is a weekday.- Returns:
- true if this DayOfWeek is Monday through Friday
- Since:
- 2.5.0
-
plus
public static java.time.Month plus(java.time.Month self, int months)Returns theMonth
that ismonths
months after this month.- Parameters:
self
- a Monthmonths
- the number of months move forward- Returns:
- the Month
- Since:
- 2.5.0
-
minus
public static java.time.Month minus(java.time.Month self, int months)Returns theMonth
that ismonths
months before this month.- Parameters:
self
- a Monthmonths
- the number of months to move back- Returns:
- the Month
- Since:
- 2.5.0
-
leftShift
public static java.time.MonthDay leftShift(java.time.Month self, int dayOfMonth)Creates aMonthDay
at the provided day of the month.- Parameters:
self
- a MonthdayOfMonth
- a day of the month- Returns:
- a MonthDay
- Since:
- 2.5.0
-
leftShift
public static java.time.YearMonth leftShift(java.time.Month self, java.time.Year year)Creates aYearMonth
at the providedYear
.- Parameters:
self
- a Monthyear
- a Year- Returns:
- a YearMonth
- Since:
- 2.5.0
-
getZoneOffset
public static java.time.ZoneOffset getZoneOffset(java.util.Calendar self)Returns the Time Zone offset of the Calendar as aZoneOffset
.- Parameters:
self
- a Calendar- Returns:
- a ZoneOffset
- Since:
- 2.5.0
-
getZoneOffset
public static java.time.ZoneOffset getZoneOffset(java.util.Date self)Returns the Time Zone offset of the Date as aZoneOffset
, which will typically be system's default offset.- Parameters:
self
- a Date- Returns:
- a ZoneOffset
- Since:
- 2.5.0
-
getZoneId
public static java.time.ZoneId getZoneId(java.util.Calendar self)Returns the Time Zone of the Calendar as a java.time.ZoneId.- Parameters:
self
- a Calendar- Returns:
- a ZoneId
- Since:
- 2.5.0
-
getZoneId
public static java.time.ZoneId getZoneId(java.util.Date self)Returns the Time Zone of the Date as aZoneId
. This will typically be the system's default ZoneId.- Parameters:
self
- a Date- Returns:
- a ZoneId
- Since:
- 2.5.0
-
toYear
public static java.time.Year toYear(java.util.Calendar self)Converts the Calendar to a correspondingYear
. If the Calendar has a different time zone than the system default, the Year will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a Year
- Since:
- 2.5.0
-
toYear
public static java.time.Year toYear(java.util.Date self)Converts the Date to a correspondingYear
.- Parameters:
self
- a Date- Returns:
- a Year
- Since:
- 2.5.0
-
toMonth
public static java.time.Month toMonth(java.util.Calendar self)Converts the Calendar to a correspondingMonth
. If the Calendar has a different time zone than the system default, the Month will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a Month
- Since:
- 2.5.0
-
toMonth
public static java.time.Month toMonth(java.util.Date self)Converts the Date to a correspondingMonth
.- Parameters:
self
- a Date- Returns:
- a Month
- Since:
- 2.5.0
-
toMonthDay
public static java.time.MonthDay toMonthDay(java.util.Calendar self)Converts the Calendar to a correspondingMonthDay
. If the Calendar has a different time zone than the system default, the MonthDay will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a MonthDay
- Since:
- 2.5.0
-
toMonthDay
public static java.time.MonthDay toMonthDay(java.util.Date self)Converts the Date to a correspondingMonthDay
.- Parameters:
self
- a Date- Returns:
- a MonthDay
- Since:
- 2.5.0
-
toYearMonth
public static java.time.YearMonth toYearMonth(java.util.Calendar self)Converts the Calendar to a correspondingYearMonth
. If the Calendar has a different time zone than the system default, the YearMonth will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a YearMonth
- Since:
- 2.5.0
-
toYearMonth
public static java.time.YearMonth toYearMonth(java.util.Date self)Converts the Date to a correspondingYearMonth
.- Parameters:
self
- a Date- Returns:
- a YearMonth
- Since:
- 2.5.0
-
toDayOfWeek
public static java.time.DayOfWeek toDayOfWeek(java.util.Calendar self)Converts the Calendar to a correspondingDayOfWeek
. If the Calendar has a different time zone than the system default, the DayOfWeek will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a DayOfWeek
- Since:
- 2.5.0
-
toDayOfWeek
public static java.time.DayOfWeek toDayOfWeek(java.util.Date self)Converts the Date to a correspondingDayOfWeek
.- Parameters:
self
- a Date- Returns:
- a DayOfWeek
- Since:
- 2.5.0
-
toLocalDate
public static java.time.LocalDate toLocalDate(java.util.Date self)Converts the Date to a correspondingLocalDate
.- Parameters:
self
- a Date- Returns:
- a LocalDate
- Since:
- 2.5.0
-
toLocalTime
public static java.time.LocalTime toLocalTime(java.util.Calendar self)Converts the Calendar to a correspondingLocalTime
. If the Calendar has a different time zone than the system default, the LocalTime will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a LocalTime
- Since:
- 2.5.0
-
toLocalTime
public static java.time.LocalTime toLocalTime(java.util.Date self)Converts the Date to a correspondingLocalTime
.- Parameters:
self
- a Date- Returns:
- a LocalTime
- Since:
- 2.5.0
-
toLocalDateTime
public static java.time.LocalDateTime toLocalDateTime(java.util.Calendar self)Converts the Calendar to a correspondingLocalDateTime
. If the Calendar has a different time zone than the system default, the LocalDateTime will be adjusted into the default time zone.- Parameters:
self
- a Calendar- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
toLocalDateTime
public static java.time.LocalDateTime toLocalDateTime(java.util.Date self)Converts the Date to a correspondingLocalDateTime
.- Parameters:
self
- a Date- Returns:
- a LocalDateTime
- Since:
- 2.5.0
-
toZonedDateTime
public static java.time.ZonedDateTime toZonedDateTime(java.util.Calendar self)Converts the Calendar to a corresponding
ZonedDateTime
.Note that
GregorianCalendar
has aGregorianCalendar.toZonedDateTime()
method, which is commonly the specific type of Calendar in use.- Parameters:
self
- a Calendar- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
toZonedDateTime
public static java.time.ZonedDateTime toZonedDateTime(java.util.Date self)Converts the Date to a correspondingZonedDateTime
.- Parameters:
self
- a Date- Returns:
- a ZonedDateTime
- Since:
- 2.5.0
-
toOffsetDateTime
public static java.time.OffsetDateTime toOffsetDateTime(java.util.Calendar self)Converts the Calendar to a correspondingOffsetDateTime
.- Parameters:
self
- a Calendar- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
toOffsetDateTime
public static java.time.OffsetDateTime toOffsetDateTime(java.util.Date self)Converts the Date to a correspondingOffsetDateTime
.- Parameters:
self
- a Date- Returns:
- an OffsetDateTime
- Since:
- 2.5.0
-
toOffsetTime
public static java.time.OffsetTime toOffsetTime(java.util.Calendar self)Converts the Calendar to a correspondingOffsetTime
.- Parameters:
self
- a Calendar- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
toOffsetTime
public static java.time.OffsetTime toOffsetTime(java.util.Date self)Converts the Date to a correspondingOffsetTime
.- Parameters:
self
- a Date- Returns:
- an OffsetTime
- Since:
- 2.5.0
-
toInstant
public static java.time.Instant toInstant(java.util.Calendar self)Convenience method for converting a Calendar to a correspondingInstant
.- Parameters:
self
- a Calendar- Returns:
- an Instant
- Since:
- 2.5.0
-
toZoneOffset
public static java.time.ZoneOffset toZoneOffset(java.util.TimeZone self)Converts the TimeZone to a correspondingZoneOffset
. The offset is determined using the current date/time.- Parameters:
self
- a TimeZone- Returns:
- a ZoneOffset
- Since:
- 2.5.0
-
toZoneOffset
public static java.time.ZoneOffset toZoneOffset(java.util.TimeZone self, java.time.Instant instant)Converts this TimeZone to a correspondingZoneOffset
. The offset is determined using the date/time of specified Instant.- Parameters:
self
- a TimeZone- Returns:
- a ZoneOffset
- Since:
- 2.5.0
-