Class DateTimeUtils
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Exception type thrown when operations on date time values would exceed the range available by max or min long nanoseconds.static class
Exception type thrown when date time string representations can not be parsed. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
One day in nanoseconds.static final double
Number of days per nanosecond.static final long
One hour in nanoseconds.static final double
Number of hours per nanosecond.static final long
One microsecond in nanoseconds.static final long
One millisecond in nanoseconds.static final long
One minute in nanoseconds.static final double
Number of minutes per nanosecond.static final long
One second in nanoseconds.static final double
Number of seconds per nanosecond.static final long
One week in nanoseconds.static final long
One 365 day year in nanoseconds.static final long
One average year in nanoseconds.static final double
Number of 365 day years per nanosecond.static final double
Number of average (365.2425 day) years per nanosecond.static final Instant[]
A zero length array ofinstants
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Instant
atMidnight
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns anInstant
for the prior midnight in the specified time zone.static @Nullable ZonedDateTime
atMidnight
(@Nullable LocalDate localDate, @Nullable ZoneId timeZone) Returns aZonedDateTime
for the prior midnight in the specified time zone.static @Nullable ZonedDateTime
atMidnight
(@Nullable LocalDateTime localDateTime, @Nullable ZoneId timeZone) Returns aZonedDateTime
for the prior midnight in the specified time zone.static @Nullable ZonedDateTime
atMidnight
(@Nullable ZonedDateTime dateTime) Returns aZonedDateTime
for the prior midnight in the specified time zone.static @NotNull Clock
Returns the clock used to compute the current time.static int
dayOfMonth
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns a 1-based int value of the day of the month for anInstant
and specified time zone.static int
dayOfMonth
(@Nullable LocalDate localDate) Returns a 1-based int value of the day of the month for aLocalDate
.static int
dayOfMonth
(@Nullable LocalDateTime localDateTime) Returns a 1-based int value of the day of the month for aLocalDateTime
.static int
dayOfMonth
(@Nullable ZonedDateTime dateTime) Returns a 1-based int value of the day of the month for aZonedDateTime
and specified time zone.static DayOfWeek
Returns the day of the week for anInstant
in the specified time zone.static DayOfWeek
Returns the day of the week for aLocalDate
.static DayOfWeek
dayOfWeek
(@Nullable LocalDateTime localDateTime) Returns athe day of the week for aZonedDateTime
.static DayOfWeek
dayOfWeek
(@Nullable ZonedDateTime dateTime) Returns the day of the week for aZonedDateTime
in the specified time zone.static int
dayOfWeekValue
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns a 1-based int value of the day of the week for anInstant
in the specified time zone, with 1 being Monday and 7 being Sunday.static int
dayOfWeekValue
(@Nullable LocalDate localDate) Returns a 1-based int value of the day of the week for aLocalDate
, with 1 being Monday and 7 being Sunday.static int
dayOfWeekValue
(@Nullable LocalDateTime localDateTime) Returns a 1-based int value of the day of the week for aLocalDateTime
, with 1 being Monday and 7 being Sunday.static int
dayOfWeekValue
(@Nullable ZonedDateTime dateTime) Returns a 1-based int value of the day of the week for aZonedDateTime
in the specified time zone, with 1 being Monday and 7 being Sunday.static int
Returns a 1-based int value of the day of the year (Julian date) for anInstant
in the specified time zone.static int
Returns a 1-based int value of the day of the year (Julian date) for aLocalDate
.static int
dayOfYear
(@Nullable LocalDateTime localDateTime) Returns a 1-based int value of the day of the year (Julian date) for aLocalDateTime
.static int
dayOfYear
(@Nullable ZonedDateTime dateTime) Returns a 1-based int value of the day of the year (Julian date) for aZonedDateTime
in the specified time zone.static double
Returns the difference in days between two instant values.static double
diffDays
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in days between two zoned date time values.static long
diffMicros
(@Nullable Instant start, @Nullable Instant end) Returns the difference in microseconds between two instant values.static long
diffMicros
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in microseconds between two zoned date time values.static long
diffMillis
(@Nullable Instant start, @Nullable Instant end) Returns the difference in milliseconds between two instant values.static long
diffMillis
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in milliseconds between two zoned date time values.static double
diffMinutes
(@Nullable Instant start, @Nullable Instant end) Returns the difference in minutes between two instant values.static double
diffMinutes
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in minutes between two zoned date time values.static long
Returns the difference in nanoseconds between two instant values.static long
diffNanos
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in nanoseconds between two zoned date time values.static double
diffSeconds
(@Nullable Instant start, @Nullable Instant end) Returns the difference in seconds between two instant values.static double
diffSeconds
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in seconds between two zoned date time values.static double
diffYears365
(@Nullable Instant start, @Nullable Instant end) Returns the difference in years between two instant values.static double
diffYears365
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in years between two zoned date time values.static double
diffYearsAvg
(@Nullable Instant start, @Nullable Instant end) Returns the difference in years between two instant values.static double
diffYearsAvg
(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end) Returns the difference in years between two zoned date time values.static Duration
Divide a duration by a scalar.static long
epochAutoToEpochNanos
(long epochOffset) Converts an offset from the Epoch to a nanoseconds from the Epoch.static @Nullable Instant
epochAutoToInstant
(long epochOffset) Converts an offset from the Epoch to anInstant
.static @Nullable ZonedDateTime
epochAutoToZonedDateTime
(long epochOffset, @Nullable ZoneId timeZone) Converts an offset from the Epoch to aZonedDateTime
.static long
Returns number of days from the Epoch for aLocalDate
value.static int
epochDaysAsInt
(@Nullable LocalDate date) Returns number of days (as anint
) from the Epoch for aLocalDate
value.static @Nullable LocalDate
epochDaysAsIntToLocalDate
(int days) Converts days from the Epoch (stored asint
) to aLocalDate
.static @Nullable LocalDate
epochDaysToLocalDate
(long days) Converts days from the Epoch to aLocalDate
.static long
epochMicros
(@Nullable Instant instant) Returns microseconds from the Epoch for anInstant
value.static long
epochMicros
(@Nullable ZonedDateTime dateTime) Returns microseconds from the Epoch for aZonedDateTime
value.static @Nullable Instant
epochMicrosToInstant
(long micros) Converts microseconds from the Epoch to anInstant
.static @Nullable ZonedDateTime
epochMicrosToZonedDateTime
(long micros, @Nullable ZoneId timeZone) Converts microseconds from the Epoch to aZonedDateTime
.static long
epochMillis
(@Nullable Instant instant) Returns milliseconds from the Epoch for anInstant
value.static long
epochMillis
(@Nullable ZonedDateTime dateTime) Returns milliseconds from the Epoch for aZonedDateTime
value.static @Nullable Instant
epochMillisToInstant
(long millis) Converts milliseconds from the Epoch to anInstant
.static @Nullable ZonedDateTime
epochMillisToZonedDateTime
(long millis, @Nullable ZoneId timeZone) Converts milliseconds from the Epoch to aZonedDateTime
.static long
epochNanos
(@Nullable Instant instant) Returns nanoseconds from the Epoch for anInstant
value.static long
epochNanos
(@Nullable ZonedDateTime dateTime) Returns nanoseconds from the Epoch for aZonedDateTime
value.static @Nullable Instant
epochNanosToInstant
(long nanos) Converts nanoseconds from the Epoch to anInstant
.static @Nullable ZonedDateTime
epochNanosToZonedDateTime
(long nanos, ZoneId timeZone) Converts nanoseconds from the Epoch to aZonedDateTime
.static long
epochSeconds
(@Nullable Instant instant) Returns seconds since from the Epoch for anInstant
value.static long
epochSeconds
(@Nullable ZonedDateTime dateTime) Returns seconds since from the Epoch for aZonedDateTime
value.static @Nullable Instant
epochSecondsToInstant
(long seconds) Converts seconds from the Epoch to anInstant
.static @Nullable ZonedDateTime
epochSecondsToZonedDateTime
(long seconds, @Nullable ZoneId timeZone) Converts seconds from the Epoch to aZonedDateTime
.static @Nullable Instant
excelToInstant
(double excel, @Nullable ZoneId timeZone) Converts an Excel time represented as a double to anInstant
.static @Nullable ZonedDateTime
excelToZonedDateTime
(double excel, @Nullable ZoneId timeZone) Converts an Excel time represented as a double to aZonedDateTime
.static @Nullable String
formatDate
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns anInstant
formatted as a "yyyy-MM-dd" string.static @Nullable String
formatDate
(@Nullable LocalDate localDate) Returns aLocalDate
formatted as a "yyyy-MM-dd" string.static @Nullable String
formatDate
(@Nullable LocalDateTime localDateTime) Returns aLocalDateTime
formatted as a "yyyy-MM-dd" string.static @Nullable String
formatDate
(@Nullable ZonedDateTime dateTime) Returns aZonedDateTime
formatted as a "yyyy-MM-dd" string.static @Nullable String
formatDateTime
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns anInstant
formatted as a "yyyy-MM-ddThh:mm:ss.SSSSSSSSS TZ" string.static @Nullable String
formatDateTime
(@Nullable ZonedDateTime dateTime) Returns aZonedDateTime
formatted as a "yyyy-MM-ddThh:mm:ss.SSSSSSSSS TZ" string.static @Nullable String
formatDurationNanos
(long nanos) Returns a nanosecond duration formatted as a "[-]PThhh:mm:ss.nnnnnnnnn" string.static int
Returns the number of hours that have elapsed since the start of the day.static int
hourOfDay
(@Nullable LocalDateTime localDateTime) Returns the number of hours that have elapsed since the start of the day.static int
Returns the number of hours that have elapsed since the start of the day.static int
hourOfDay
(@Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of hours that have elapsed since the start of the day.static boolean
Evaluates whether one instant value is after a second instant value.static boolean
isAfter
(@Nullable ZonedDateTime dateTime1, @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is after a second zoned date time value.static boolean
isAfterOrEqual
(@Nullable Instant instant1, @Nullable Instant instant2) Evaluates whether one instant value is after or equal to a second instant value.static boolean
isAfterOrEqual
(@Nullable ZonedDateTime dateTime1, @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is after or equal to a second zoned date time value.static boolean
Evaluates whether one instant value is before a second instant value.static boolean
isBefore
(@Nullable ZonedDateTime dateTime1, @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is before a second zoned date time value.static boolean
isBeforeOrEqual
(@Nullable Instant instant1, @Nullable Instant instant2) Evaluates whether one instant value is before or equal to a second instant value.static boolean
isBeforeOrEqual
(@Nullable ZonedDateTime dateTime1, @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is before or equal to a second zoned date time value.static @Nullable Instant
Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable Instant
Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable Instant
Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable Instant
Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
lowerBin
(@Nullable ZonedDateTime dateTime, long intervalNanos) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
lowerBin
(@Nullable ZonedDateTime dateTime, long intervalNanos, long offset) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
lowerBin
(@Nullable ZonedDateTime dateTime, Duration interval) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
lowerBin
(@Nullable ZonedDateTime dateTime, Duration interval, Duration offset) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds.static @Nullable LocalTime
microsOfDayToLocalTime
(long micros) Converts the number of microseconds from midnight to aLocalTime
static int
microsOfMilli
(@Nullable Instant instant) Returns the number of microseconds that have elapsed since the top of the millisecond.static int
microsOfMilli
(@Nullable ZonedDateTime dateTime) Returns the number of microseconds that have elapsed since the top of the millisecond.static long
microsOfSecond
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns the number of microseconds that have elapsed since the top of the second.static long
microsOfSecond
(@Nullable ZonedDateTime dateTime) Returns the number of microseconds that have elapsed since the top of the second.static long
microsToMillis
(long micros) Converts microseconds to milliseconds.static long
microsToNanos
(long micros) Converts microseconds to nanoseconds.static long
microsToSeconds
(long micros) Converts microseconds to seconds.static int
millisOfDay
(@Nullable Instant instant, @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of milliseconds that have elapsed since the start of the day.static int
millisOfDay
(@Nullable LocalDateTime localDateTime) Returns the number of milliseconds that have elapsed since the start of the day.static int
millisOfDay
(@Nullable LocalTime localTime) Returns the number of milliseconds that have elapsed since the start of the day.static int
millisOfDay
(@Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of milliseconds that have elapsed since the start of the day.static @Nullable LocalTime
millisOfDayToLocalTime
(int millis) Converts the number of milliseconds from midnight to aLocalTime
static int
millisOfSecond
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns the number of milliseconds that have elapsed since the top of the second.static int
millisOfSecond
(@Nullable ZonedDateTime dateTime) Returns the number of milliseconds that have elapsed since the top of the second.static long
millisToMicros
(long millis) Converts milliseconds to microseconds.static long
millisToNanos
(long millis) Converts milliseconds to nanoseconds.static long
millisToSeconds
(long millis) Converts milliseconds to seconds.static Duration
Subtracts two durations.static @Nullable Instant
Subtracts nanoseconds from anInstant
.static @Nullable Instant
Subtracts a time period to anInstant
.static long
Subtract one instant from another and return the difference in nanoseconds.static @Nullable Instant
Subtracts a time period to anInstant
.static @Nullable LocalDate
Subtracts a time period from aLocalDate
.static @Nullable LocalDateTime
minus
(@Nullable LocalDateTime localDateTime, Period period) Subtracts a time period from aLocalDateTime
.static Period
Subtracts two periods.static @Nullable ZonedDateTime
minus
(@Nullable ZonedDateTime dateTime, long nanos) Subtracts nanoseconds from aZonedDateTime
.static @Nullable ZonedDateTime
minus
(@Nullable ZonedDateTime dateTime, @Nullable Duration duration) Subtracts a time period to aZonedDateTime
.static @Nullable ZonedDateTime
minus
(@Nullable ZonedDateTime dateTime, @Nullable Period period) Subtracts a time period to aZonedDateTime
.static long
minus
(@Nullable ZonedDateTime dateTime1, @Nullable ZonedDateTime dateTime2) Subtract one zoned date time from another and return the difference in nanoseconds.static @Nullable LocalDate
Subtracts days from aLocalDate
.static @Nullable LocalDateTime
minusDays
(@Nullable LocalDateTime localDateTime, long days) Subtracts days from aLocalDate
.static int
minuteOfDay
(@Nullable Instant instant, @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of minutes that have elapsed since the start of the day.static int
minuteOfDay
(@Nullable LocalDateTime localDateTime) Returns the number of minutes that have elapsed since the start of the day.static int
minuteOfDay
(@Nullable LocalTime localTime) Returns the number of minutes that have elapsed since the start of the day.static int
minuteOfDay
(@Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of minutes that have elapsed since the start of the day.static int
minuteOfHour
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns the number of minutes that have elapsed since the top of the hour.static int
minuteOfHour
(@Nullable ZonedDateTime dateTime) Returns the number of minutes that have elapsed since the top of the hour.static int
monthOfYear
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns a 1-based int value of the month of the year (Julian date) for anInstant
in the specified time zone.static int
monthOfYear
(@Nullable LocalDate localDate) Returns a 1-based int value of the month of the year (Julian date) for aLocalDate
.static int
monthOfYear
(@Nullable LocalDateTime localDateTime) Returns a 1-based int value of the month of the year (Julian date) for aLocalDateTime
.static int
monthOfYear
(@Nullable ZonedDateTime dateTime) Returns a 1-based int value of the month of the year (Julian date) for aZonedDateTime
in the specified time zone.static Period
Multiply a period by a scalar.static Duration
Multiply a duration by a scalar.static Duration
Multiply a duration by a scalar.static Period
Multiply a period by a scalar.static long
nanosOfDay
(@Nullable Instant instant, @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of nanoseconds that have elapsed since the start of the day.static long
nanosOfDay
(@Nullable LocalDateTime localDateTime) Returns the number of nanoseconds that have elapsed since the start of the day.static long
nanosOfDay
(@Nullable LocalTime localTime) Returns the number of nanoseconds that have elapsed since the start of the day.static long
nanosOfDay
(@Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of nanoseconds that have elapsed since the start of the day.static @Nullable LocalTime
nanosOfDayToLocalTime
(long nanos) Converts the number of nanoseconds from midnight to aLocalTime
static int
nanosOfMilli
(@Nullable Instant instant) Returns the number of nanoseconds that have elapsed since the top of the millisecond.static int
nanosOfMilli
(@Nullable ZonedDateTime dateTime) Returns the number of nanoseconds that have elapsed since the top of the millisecond.static long
nanosOfSecond
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns the number of nanoseconds that have elapsed since the top of the second.static long
nanosOfSecond
(@Nullable ZonedDateTime dateTime) Returns the number of nanoseconds that have elapsed since the top of the second.static long
nanosToMicros
(long nanos) Converts nanoseconds to microseconds.static long
nanosToMillis
(long nanos) Converts nanoseconds to milliseconds.static long
nanosToSeconds
(long nanos) Converts nanoseconds to seconds.static @NotNull Instant
now()
Provides the currentinstant
with nanosecond resolution according to thecurrent clock
.static @NotNull Instant
Provides the currentinstant
with millisecond resolution according to thecurrent clock
.static @NotNull Instant
Provides the currentinstant
with nanosecond resolution according to thesystem clock
.static @NotNull Instant
Provides the currentinstant
with millisecond resolution according to thesystem clock
.static @NotNull Duration
parseDuration
(@NotNull String s) Parses the string argument as a duration, which is a unit of time in terms of clock time (24-hour days, hours, minutes, seconds, and nanoseconds).static long
parseDurationNanos
(@NotNull String s) Parses the string argument as a time duration in nanoseconds.static long
parseDurationNanosQuiet
(@Nullable String s) Parses the string argument as a time duration in nanoseconds.static @Nullable Duration
parseDurationQuiet
(@Nullable String s) Parses the string argument as a duration, which is a unit of time in terms of clock time (24-hour days, hours, minutes, seconds, and nanoseconds).static long
parseEpochNanos
(@NotNull String s) Parses the string argument as nanoseconds since the Epoch.static long
parseEpochNanosQuiet
(@Nullable String s) Parses the string argument as a nanoseconds since the Epoch.static @NotNull Instant
parseInstant
(@NotNull String s) Parses the string argument as anInstant
.static @Nullable Instant
parseInstantQuiet
(@Nullable String s) Parses the string argument as anInstant
.static @NotNull LocalDate
parseLocalDate
(@NotNull String s) Parses the string argument as a local date, which is a date without a time or time zone.static @Nullable LocalDate
parseLocalDateQuiet
(@Nullable String s) Parses the string argument as a local date, which is a date without a time or time zone.static @NotNull LocalDateTime
parseLocalDateTime
(@NotNull String s) Parses the string argument as aLocalDateTime
.static @Nullable LocalDateTime
parseLocalDateTimeQuiet
(@Nullable String s) Parses the string argument as aLocalDateTime
.static @NotNull LocalTime
parseLocalTime
(@NotNull String s) Parses the string argument as a local time, which is the time that would be read from a clock and does not have a date or timezone.static @Nullable LocalTime
parseLocalTimeQuiet
(@Nullable String s) Parses the string argument as a local time, which is the time that would be read from a clock and does not have a date or timezone.static @NotNull Period
parsePeriod
(@NotNull String s) Parses the string argument as a period, which is a unit of time in terms of calendar time (days, weeks, months, years, etc.).static @Nullable Period
parsePeriodQuiet
(@Nullable String s) Parses the string argument as a period, which is a unit of time in terms of calendar time (days, weeks, months, years, etc.).static @NotNull ChronoField
parseTimePrecision
(@NotNull String s) Returns aChronoField
indicating the level of precision in a time, datetime, or period nanos string.static @Nullable ChronoField
parseTimePrecisionQuiet
(@Nullable String s) Returns aChronoField
indicating the level of precision in a time or datetime string.static @NotNull ZoneId
parseTimeZone
(@NotNull String s) Parses the string argument as a time zone.static @Nullable ZoneId
parseTimeZoneQuiet
(@Nullable String s) Parses the string argument as a time zone.static @NotNull ZonedDateTime
parseZonedDateTime
(@NotNull String s) Parses the string argument as aZonedDateTime
.static @Nullable ZonedDateTime
parseZonedDateTimeQuiet
(@Nullable String s) Parses the string argument as aZonedDateTime
.static Duration
Adds two durations.static @Nullable Instant
Adds nanoseconds to anInstant
.static @Nullable Instant
Adds a time period to anInstant
.static @Nullable Instant
Adds a time period to anInstant
.static @Nullable LocalDate
Adds a time period to aLocalDate
.static @Nullable LocalDateTime
plus
(@Nullable LocalDateTime localDateTime, Period period) Adds a time period to aLocalDateTime
.static Period
Adds two periods.static @Nullable ZonedDateTime
plus
(@Nullable ZonedDateTime dateTime, long nanos) Adds nanoseconds to aZonedDateTime
.static @Nullable ZonedDateTime
plus
(@Nullable ZonedDateTime dateTime, @Nullable Duration duration) Adds a time period to aZonedDateTime
.static @Nullable ZonedDateTime
plus
(@Nullable ZonedDateTime dateTime, @Nullable Period period) Adds a time period to aZonedDateTime
.static @Nullable LocalDate
Adds days to aLocalDate
.static @Nullable LocalDateTime
plusDays
(@Nullable LocalDateTime localDateTime, long days) Adds days to aLocalDate
.static int
secondOfDay
(@Nullable Instant instant, @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of seconds that have elapsed since the start of the day.static int
secondOfDay
(@Nullable LocalDateTime localDateTime) Returns the number of seconds that have elapsed since the start of the day.static int
secondOfDay
(@Nullable LocalTime localTime) Returns the number of seconds that have elapsed since the start of the day.static int
secondOfDay
(@Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of seconds that have elapsed since the start of the day.static int
secondOfMinute
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns the number of seconds that have elapsed since the top of the minute.static int
secondOfMinute
(@Nullable ZonedDateTime dateTime) Returns the number of seconds that have elapsed since the top of the minute.static long
secondsToMicros
(long seconds) Converts seconds to microseconds.static long
secondsToMillis
(long seconds) Converts seconds to milliseconds.static long
secondsToNanos
(long seconds) Converts seconds to nanoseconds.static void
Set the clock used to compute the current time.static ZoneId
timeZone()
Gets thesystem default time zone
.static @Nullable ZoneId
Gets the time zone for a time zone name.static void
timeZoneAliasAdd
(@NotNull String alias, @NotNull String timeZone) Adds a new time zone alias.static boolean
timeZoneAliasRm
(@NotNull String alias) Removes a time zone alias.static @Nullable Date
Deprecated.static @Nullable Date
toDate
(@Nullable ZonedDateTime dateTime) Deprecated.static @NotNull String
today()
Provides the current date string according to thecurrent clock
and thedefault time zone
.static @Nullable String
Provides the current date string according to thecurrent clock
.static @NotNull LocalDate
Provides the current date according to thecurrent clock
and thedefault time zone
.static @Nullable LocalDate
todayLocalDate
(@Nullable ZoneId timeZone) Provides the current date according to thecurrent clock
.static double
toExcelTime
(@Nullable Instant instant, @Nullable ZoneId timeZone) Converts anInstant
to an Excel time represented as a double.static double
toExcelTime
(@Nullable ZonedDateTime dateTime) Converts aZonedDateTime
to an Excel time represented as a double.static @Nullable Instant
static @Nullable Instant
toInstant
(@Nullable LocalDateTime localDateTime, @Nullable ZoneId timeZone) static @Nullable Instant
toInstant
(@Nullable ZonedDateTime dateTime) Converts aZonedDateTime
to anInstant
.static @Nullable Instant
Deprecated.static @Nullable LocalDate
toLocalDate
(@Nullable Instant instant, @Nullable ZoneId timeZone) static @Nullable LocalDate
toLocalDate
(@Nullable LocalDateTime localDateTime) Gets theLocalDate
portion of aLocalDateTime
.static @Nullable LocalDate
toLocalDate
(@Nullable ZonedDateTime dateTime) Gets theLocalDate
portion of aZonedDateTime
.static @Nullable LocalDateTime
toLocalDateTime
(@Nullable Instant instant, @Nullable ZoneId timeZone) static @Nullable LocalDateTime
toLocalDateTime
(@Nullable LocalDate localDate, @Nullable LocalTime localTime) static @Nullable LocalDateTime
toLocalDateTime
(@Nullable ZonedDateTime dateTime) Gets theLocalDateTime
portion of aZonedDateTime
.static @Nullable LocalTime
toLocalTime
(@Nullable Instant instant, @Nullable ZoneId timeZone) static @Nullable LocalTime
toLocalTime
(@Nullable LocalDateTime localDateTime) Gets theLocalTime
portion of aLocalDateTime
.static @Nullable LocalTime
toLocalTime
(@Nullable ZonedDateTime dateTime) Gets theLocalTime
portion of aZonedDateTime
.static @Nullable ZonedDateTime
toZonedDateTime
(@Nullable Instant instant, @Nullable ZoneId timeZone) Converts anInstant
to aZonedDateTime
.static @Nullable ZonedDateTime
toZonedDateTime
(@Nullable LocalDate date, @Nullable LocalTime time, @Nullable ZoneId timeZone) static @Nullable ZonedDateTime
toZonedDateTime
(@Nullable LocalDateTime localDateTime, @Nullable ZoneId timeZone) static @Nullable Instant
Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable Instant
Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable Instant
Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable Instant
Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
upperBin
(@Nullable ZonedDateTime dateTime, long intervalNanos) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
upperBin
(@Nullable ZonedDateTime dateTime, long intervalNanos, long offset) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
upperBin
(@Nullable ZonedDateTime dateTime, Duration interval) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static @Nullable ZonedDateTime
upperBin
(@Nullable ZonedDateTime dateTime, Duration interval, Duration offset) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds.static int
Returns the year for anInstant
in the specified time zone.static int
Returns the year for aLocalDate
.static int
year
(@Nullable LocalDateTime localDateTime) Returns the year for aLocalDateTime
.static int
year
(@Nullable ZonedDateTime dateTime) Returns the year for aZonedDateTime
in the specified time zone.static int
yearOfCentury
(@Nullable Instant instant, @Nullable ZoneId timeZone) Returns the year of the century (two-digit year) for anInstant
in the specified time zone.static int
yearOfCentury
(@Nullable LocalDate localDate) Returns the year of the century (two-digit year) for aLocalDate
.static int
yearOfCentury
(@Nullable LocalDateTime localDateTime) Returns the year of the century (two-digit year) for aLocalDateTime
.static int
yearOfCentury
(@Nullable ZonedDateTime dateTime) Returns the year of the century (two-digit year) for aZonedDateTime
in the specified time zone.
-
Field Details
-
ZERO_LENGTH_INSTANT_ARRAY
A zero length array ofinstants
. -
MICRO
public static final long MICROOne microsecond in nanoseconds.- See Also:
-
MILLI
public static final long MILLIOne millisecond in nanoseconds.- See Also:
-
SECOND
public static final long SECONDOne second in nanoseconds.- See Also:
-
MINUTE
public static final long MINUTEOne minute in nanoseconds.- See Also:
-
HOUR
public static final long HOUROne hour in nanoseconds.- See Also:
-
DAY
public static final long DAYOne day in nanoseconds. This is one hour of wall time and does not take into account calendar adjustments.- See Also:
-
WEEK
public static final long WEEKOne week in nanoseconds. This is 7 days of wall time and does not take into account calendar adjustments.- See Also:
-
YEAR_365
public static final long YEAR_365One 365 day year in nanoseconds. This is 365 days of wall time and does not take into account calendar adjustments.- See Also:
-
YEAR_AVG
public static final long YEAR_AVGOne average year in nanoseconds. This is 365.2425 days of wall time and does not take into account calendar adjustments.- See Also:
-
SECONDS_PER_NANO
public static final double SECONDS_PER_NANONumber of seconds per nanosecond.- See Also:
-
MINUTES_PER_NANO
public static final double MINUTES_PER_NANONumber of minutes per nanosecond.- See Also:
-
HOURS_PER_NANO
public static final double HOURS_PER_NANONumber of hours per nanosecond.- See Also:
-
DAYS_PER_NANO
public static final double DAYS_PER_NANONumber of days per nanosecond.- See Also:
-
YEARS_PER_NANO_365
public static final double YEARS_PER_NANO_365Number of 365 day years per nanosecond.- See Also:
-
YEARS_PER_NANO_AVG
public static final double YEARS_PER_NANO_AVGNumber of average (365.2425 day) years per nanosecond.- See Also:
-
-
Constructor Details
-
DateTimeUtils
public DateTimeUtils()
-
-
Method Details
-
setClock
Set the clock used to compute the current time. This allows a custom clock to be used instead of the current system clock. This is mainly used for replay simulations.- Parameters:
clock
- the clock used to compute the current time; ifnull
, use the system clock
-
currentClock
Returns the clock used to compute the current time. This may be the current system clock, or it may be an alternative clock used for replay simulations.- Returns:
- the current clock
- See Also:
-
now
Provides the currentinstant
with nanosecond resolution according to thecurrent clock
. Under most circumstances, this method will return the current system time, but during replay simulations, this method can return the replay time.- Returns:
- the current instant with nanosecond resolution according to the current clock
- See Also:
-
nowMillisResolution
Provides the currentinstant
with millisecond resolution according to thecurrent clock
. Under most circumstances, this method will return the current system time, but during replay simulations, this method can return the replay time.- Returns:
- the current instant with millisecond resolution according to the current clock
- See Also:
-
nowSystem
Provides the currentinstant
with nanosecond resolution according to thesystem clock
. Note that the system time may not be desirable during replay simulations.- Returns:
- the current instant with nanosecond resolution according to the system clock
- See Also:
-
nowSystemMillisResolution
Provides the currentinstant
with millisecond resolution according to thesystem clock
. Note that the system time may not be desirable during replay simulations.- Returns:
- the current instant with millisecond resolution according to the system clock
- See Also:
-
today
Provides the current date string according to thecurrent clock
. Under most circumstances, this method will return the date according to current system time, but during replay simulations, this method can return the date according to replay time.- Parameters:
timeZone
- the time zone- Returns:
- the current date according to the current clock and time zone formatted as "yyyy-MM-dd".
null
if the input isnull
. - See Also:
-
today
Provides the current date string according to thecurrent clock
and thedefault time zone
. Under most circumstances, this method will return the date according to current system time, but during replay simulations, this method can return the date according to replay time.- Returns:
- the current date according to the current clock and default time zone formatted as "yyyy-MM-dd"
- See Also:
-
todayLocalDate
@ScriptApi @Nullable public static @Nullable LocalDate todayLocalDate(@Nullable @Nullable ZoneId timeZone) Provides the current date according to thecurrent clock
. Under most circumstances, this method will return the date according to current system time, but during replay simulations, this method can return the date according to replay time.- Parameters:
timeZone
- the time zone- Returns:
- the current date according to the current clock and time zone formatted as "yyyy-MM-dd".
null
if the input isnull
. - See Also:
-
todayLocalDate
Provides the current date according to thecurrent clock
and thedefault time zone
. Under most circumstances, this method will return the date according to current system time, but during replay simulations, this method can return the date according to replay time.- Returns:
- the current date according to the current clock and default time zone formatted as "yyyy-MM-dd"
- See Also:
-
timeZone
Gets the time zone for a time zone name.- Parameters:
timeZone
- the time zone name- Returns:
- the corresponding time zone.
null
if the input isnull
. - Throws:
DateTimeException
- iftimeZone
has an invalid formatZoneRulesException
- iftimeZone
cannot be found
-
timeZone
Gets thesystem default time zone
.- Returns:
- the system default time zone
- See Also:
-
timeZoneAliasAdd
@ScriptApi public static void timeZoneAliasAdd(@NotNull @NotNull String alias, @NotNull @NotNull String timeZone) Adds a new time zone alias.- Parameters:
alias
- the alias nametimeZone
- the time zone id name- Throws:
IllegalArgumentException
- if the alias already exists or the time zone is invalid
-
timeZoneAliasRm
Removes a time zone alias.- Parameters:
alias
- the alias name- Returns:
- whether
alias
was present
-
microsToNanos
Converts microseconds to nanoseconds.- Parameters:
micros
- the microseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input microseconds converted to nanoseconds
-
millisToNanos
Converts milliseconds to nanoseconds.- Parameters:
millis
- the milliseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input milliseconds converted to nanoseconds
-
secondsToNanos
Converts seconds to nanoseconds.- Parameters:
seconds
- the seconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input seconds converted to nanoseconds
-
nanosToMicros
Converts nanoseconds to microseconds.- Parameters:
nanos
- the nanoseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input nanoseconds converted to microseconds, rounded down
-
millisToMicros
Converts milliseconds to microseconds.- Parameters:
millis
- the milliseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input milliseconds converted to microseconds, rounded down
-
secondsToMicros
Converts seconds to microseconds.- Parameters:
seconds
- the seconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input seconds converted to microseconds, rounded down
-
nanosToMillis
Converts nanoseconds to milliseconds.- Parameters:
nanos
- the nanoseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input nanoseconds converted to milliseconds, rounded down
-
microsToMillis
Converts microseconds to milliseconds.- Parameters:
micros
- the microseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input microseconds converted to milliseconds, rounded down
-
secondsToMillis
Converts seconds to milliseconds.- Parameters:
seconds
- the nanoseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input seconds converted to milliseconds, rounded down
-
nanosToSeconds
Converts nanoseconds to seconds.- Parameters:
nanos
- the nanoseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input nanoseconds converted to seconds, rounded down
-
microsToSeconds
Converts microseconds to seconds.- Parameters:
micros
- the microseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input microseconds converted to seconds, rounded down
-
millisToSeconds
Converts milliseconds to seconds.- Parameters:
millis
- the milliseconds to convert- Returns:
QueryConstants.NULL_LONG
if the input isQueryConstants.NULL_LONG
; otherwise the input milliseconds converted to seconds, rounded down
-
toInstant
@ScriptApi @Nullable public static @Nullable Instant toInstant(@Nullable @Nullable ZonedDateTime dateTime) Converts aZonedDateTime
to anInstant
.- Parameters:
dateTime
- the zoned date time to convert- Returns:
- the
Instant
, ornull
ifdateTime
isnull
-
toInstant
@ScriptApi @Nullable public static @Nullable Instant toInstant(@Nullable @Nullable LocalDateTime localDateTime, @Nullable @Nullable ZoneId timeZone) - Parameters:
localDateTime
- the local date timetimeZone
- the time zone- Returns:
- the
Instant
, ornull
if any input isnull
-
toInstant
@ScriptApi @Nullable public static @Nullable Instant toInstant(@Nullable @Nullable LocalDate date, @Nullable @Nullable LocalTime time, @Nullable @Nullable ZoneId timeZone) - Parameters:
date
- the local datetime
- the local timetimeZone
- the time zone- Returns:
- the
Instant
, ornull
if any input isnull
-
toInstant
@Deprecated @ScriptApi @Nullable public static @Nullable Instant toInstant(@Nullable @Nullable Date date) Deprecated.- Parameters:
date
- the date to convert- Returns:
- the
Instant
, ornull
ifdate
isnull
-
toZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime toZonedDateTime(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Converts anInstant
to aZonedDateTime
.- Parameters:
instant
- the instant to converttimeZone
- the time zone to use- Returns:
- the
ZonedDateTime
, ornull
if any input isnull
-
toZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime toZonedDateTime(@Nullable @Nullable LocalDateTime localDateTime, @Nullable @Nullable ZoneId timeZone) - Parameters:
localDateTime
- the local date timetimeZone
- the time zone- Returns:
- the
ZonedDateTime
, ornull
if any input isnull
-
toZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime toZonedDateTime(@Nullable @Nullable LocalDate date, @Nullable @Nullable LocalTime time, @Nullable @Nullable ZoneId timeZone) - Parameters:
date
- the local datetime
- the local timetimeZone
- the time zone to use- Returns:
- the
ZonedDateTime
, ornull
if any input isnull
-
toLocalDateTime
@ScriptApi @Nullable public static @Nullable LocalDateTime toLocalDateTime(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) - Parameters:
instant
- the instant to converttimeZone
- the time zone- Returns:
- the
LocalDateTime
, ornull
if any input isnull
-
toLocalDateTime
@ScriptApi @Nullable public static @Nullable LocalDateTime toLocalDateTime(@Nullable @Nullable ZonedDateTime dateTime) Gets theLocalDateTime
portion of aZonedDateTime
.- Parameters:
dateTime
- the zoned date time to convert- Returns:
- the
LocalDateTime
, ornull
ifdateTime
isnull
-
toLocalDateTime
@ScriptApi @Nullable public static @Nullable LocalDateTime toLocalDateTime(@Nullable @Nullable LocalDate localDate, @Nullable @Nullable LocalTime localTime) - Parameters:
localDate
- the local date to convertlocalTime
- the local time to convert- Returns:
- the
LocalDateTime
, ornull
iflocalDateTime
isnull
-
toLocalDate
@ScriptApi @Nullable public static @Nullable LocalDate toLocalDate(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) - Parameters:
instant
- the instant to converttimeZone
- the time zone- Returns:
- the
LocalDate
, ornull
if any input isnull
-
toLocalDate
@ScriptApi @Nullable public static @Nullable LocalDate toLocalDate(@Nullable @Nullable ZonedDateTime dateTime) Gets theLocalDate
portion of aZonedDateTime
.- Parameters:
dateTime
- the zoned date time to convert- Returns:
- the
LocalDate
, ornull
ifdateTime
isnull
-
toLocalDate
@ScriptApi @Nullable public static @Nullable LocalDate toLocalDate(@Nullable @Nullable LocalDateTime localDateTime) Gets theLocalDate
portion of aLocalDateTime
.- Parameters:
localDateTime
- the local date time to convert- Returns:
- the
LocalDate
, ornull
iflocalDateTime
isnull
-
toLocalTime
@ScriptApi @Nullable public static @Nullable LocalTime toLocalTime(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) - Parameters:
instant
- the instant to converttimeZone
- the time zone- Returns:
- the
LocalTime
, ornull
if any input isnull
-
toLocalTime
@ScriptApi @Nullable public static @Nullable LocalTime toLocalTime(@Nullable @Nullable ZonedDateTime dateTime) Gets theLocalTime
portion of aZonedDateTime
.- Parameters:
dateTime
- the zoned date time to convert- Returns:
- the
LocalTime
, ornull
ifdateTime
isnull
-
toLocalTime
@ScriptApi @Nullable public static @Nullable LocalTime toLocalTime(@Nullable @Nullable LocalDateTime localDateTime) Gets theLocalTime
portion of aLocalDateTime
.- Parameters:
localDateTime
- the local date time to convert- Returns:
- the
LocalTime
, ornull
iflocalDateTime
isnull
-
millisOfDayToLocalTime
Converts the number of milliseconds from midnight to aLocalTime
-
microsOfDayToLocalTime
Converts the number of microseconds from midnight to aLocalTime
-
nanosOfDayToLocalTime
Converts the number of nanoseconds from midnight to aLocalTime
-
toDate
@Deprecated @ScriptApi @Nullable public static @Nullable Date toDate(@Nullable @Nullable Instant instant) Deprecated.- Parameters:
instant
- the instant to convert- Returns:
- the
Date
, ornull
ifinstant
isnull
-
toDate
@Deprecated @ScriptApi @Nullable public static @Nullable Date toDate(@Nullable @Nullable ZonedDateTime dateTime) Deprecated.- Parameters:
dateTime
- the zoned date time to convert- Returns:
- the
Date
, ornull
ifdateTime
isnull
-
epochNanos
Returns nanoseconds from the Epoch for anInstant
value.- Parameters:
instant
- instant to compute the Epoch offset for- Returns:
- nanoseconds since Epoch, or a NULL_LONG value if the instant is null
-
epochNanos
Returns nanoseconds from the Epoch for aZonedDateTime
value.- Parameters:
dateTime
- the zoned date time to compute the Epoch offset for- Returns:
- nanoseconds since Epoch, or a NULL_LONG value if the zoned date time is null
-
epochMicros
Returns microseconds from the Epoch for anInstant
value.- Parameters:
instant
- instant to compute the Epoch offset for- Returns:
- microseconds since Epoch, or a
NULL_LONG
value if the instant isnull
-
epochMicros
Returns microseconds from the Epoch for aZonedDateTime
value.- Parameters:
dateTime
- zoned date time to compute the Epoch offset for- Returns:
- microseconds since Epoch, or a
NULL_LONG
value if the zoned date time isnull
-
epochMillis
Returns milliseconds from the Epoch for anInstant
value.- Parameters:
instant
- instant to compute the Epoch offset for- Returns:
- milliseconds since Epoch, or a
NULL_LONG
value if the instant isnull
-
epochMillis
Returns milliseconds from the Epoch for aZonedDateTime
value.- Parameters:
dateTime
- zoned date time to compute the Epoch offset for- Returns:
- milliseconds since Epoch, or a
NULL_LONG
value if the zoned date time isnull
-
epochSeconds
Returns seconds since from the Epoch for anInstant
value.- Parameters:
instant
- instant to compute the Epoch offset for- Returns:
- seconds since Epoch, or a
NULL_LONG
value if the instant isnull
-
epochSeconds
Returns seconds since from the Epoch for aZonedDateTime
value.- Parameters:
dateTime
- zoned date time to compute the Epoch offset for- Returns:
- seconds since Epoch, or a
NULL_LONG
value if the zoned date time isnull
-
epochDays
Returns number of days from the Epoch for aLocalDate
value.- Parameters:
date
- date to compute the Epoch offset for- Returns:
- days since Epoch, or a
NULL_LONG
value if the instant isnull
-
epochDaysAsInt
Returns number of days (as anint
) from the Epoch for aLocalDate
value.- Parameters:
date
- date to compute the Epoch offset for- Returns:
- days since Epoch, or a
NULL_INT
value if the instant isnull
-
epochNanosToInstant
Converts nanoseconds from the Epoch to anInstant
.- Parameters:
nanos
- nanoseconds since Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input nanoseconds from the Epoch converted to anInstant
-
epochMicrosToInstant
Converts microseconds from the Epoch to anInstant
.- Parameters:
micros
- microseconds since Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input microseconds from the Epoch converted to anInstant
-
epochMillisToInstant
Converts milliseconds from the Epoch to anInstant
.- Parameters:
millis
- milliseconds since Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input milliseconds from the Epoch converted to anInstant
-
epochSecondsToInstant
Converts seconds from the Epoch to anInstant
.- Parameters:
seconds
- seconds since Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input seconds from the Epoch converted to anInstant
-
epochNanosToZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime epochNanosToZonedDateTime(long nanos, ZoneId timeZone) Converts nanoseconds from the Epoch to aZonedDateTime
.- Parameters:
nanos
- nanoseconds since EpochtimeZone
- time zone- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input nanoseconds from the Epoch converted to aZonedDateTime
-
epochMicrosToZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime epochMicrosToZonedDateTime(long micros, @Nullable @Nullable ZoneId timeZone) Converts microseconds from the Epoch to aZonedDateTime
.- Parameters:
micros
- microseconds since EpochtimeZone
- time zone- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input microseconds from the Epoch converted to aZonedDateTime
-
epochMillisToZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime epochMillisToZonedDateTime(long millis, @Nullable @Nullable ZoneId timeZone) Converts milliseconds from the Epoch to aZonedDateTime
.- Parameters:
millis
- milliseconds since EpochtimeZone
- time zone- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input milliseconds from the Epoch converted to aZonedDateTime
-
epochSecondsToZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime epochSecondsToZonedDateTime(long seconds, @Nullable @Nullable ZoneId timeZone) Converts seconds from the Epoch to aZonedDateTime
.- Parameters:
seconds
- seconds since EpochtimeZone
- time zone- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input seconds from the Epoch converted to aZonedDateTime
-
epochAutoToEpochNanos
Converts an offset from the Epoch to a nanoseconds from the Epoch. The offset can be in milliseconds, microseconds, or nanoseconds. Expected date ranges are used to infer the units for the offset.- Parameters:
epochOffset
- time offset from the Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input offset from the Epoch converted to nanoseconds from the Epoch
-
epochAutoToInstant
Converts an offset from the Epoch to anInstant
. The offset can be in milliseconds, microseconds, or nanoseconds. Expected date ranges are used to infer the units for the offset.- Parameters:
epochOffset
- time offset from the Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input offset from the Epoch converted to anInstant
-
epochAutoToZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime epochAutoToZonedDateTime(long epochOffset, @Nullable @Nullable ZoneId timeZone) Converts an offset from the Epoch to aZonedDateTime
. The offset can be in milliseconds, microseconds, or nanoseconds. Expected date ranges are used to infer the units for the offset.- Parameters:
epochOffset
- time offset from the EpochtimeZone
- time zone- Returns:
null
if any input isnull
orQueryConstants.NULL_LONG
; otherwise the input offset from the Epoch converted to aZonedDateTime
-
epochDaysToLocalDate
Converts days from the Epoch to aLocalDate
.- Parameters:
days
- days since Epoch- Returns:
null
if the input isQueryConstants.NULL_LONG
; otherwise the input days from the Epoch converted to aLocalDate
-
epochDaysAsIntToLocalDate
Converts days from the Epoch (stored asint
) to aLocalDate
.- Parameters:
days
- days since Epoch- Returns:
null
if the input isQueryConstants.NULL_INT
; otherwise the input days from the Epoch converted to aLocalDate
-
toExcelTime
@ScriptApi public static double toExcelTime(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Converts anInstant
to an Excel time represented as a double.- Parameters:
instant
- instant to converttimeZone
- time zone to use when interpreting the instant- Returns:
- 0.0 if either input is
null
; otherwise, the input instant converted to an Excel time represented as a double
-
toExcelTime
Converts aZonedDateTime
to an Excel time represented as a double.- Parameters:
dateTime
- zoned date time to convert- Returns:
- 0.0 if either input is
null
; otherwise, the input zoned date time converted to an Excel time represented as a double
-
excelToInstant
@ScriptApi @Nullable public static @Nullable Instant excelToInstant(double excel, @Nullable @Nullable ZoneId timeZone) Converts an Excel time represented as a double to anInstant
.- Parameters:
excel
- excel time represented as a doubletimeZone
- time zone to use when interpreting the Excel time- Returns:
null
if timeZone isnull
; otherwise, the input Excel time converted to anInstant
-
excelToZonedDateTime
@ScriptApi @Nullable public static @Nullable ZonedDateTime excelToZonedDateTime(double excel, @Nullable @Nullable ZoneId timeZone) Converts an Excel time represented as a double to aZonedDateTime
.- Parameters:
excel
- excel time represented as a doubletimeZone
- time zone to use when interpreting the Excel time- Returns:
null
if timeZone isnull
; otherwise, the input Excel time converted to aZonedDateTime
-
plusDays
@ScriptApi @Nullable public static @Nullable LocalDateTime plusDays(@Nullable @Nullable LocalDateTime localDateTime, long days) Adds days to aLocalDate
.- Parameters:
localDateTime
- starting local date timedays
- number of days to add- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting local date time plus the specified number of days- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plusDays
@ScriptApi @Nullable public static @Nullable LocalDate plusDays(@Nullable @Nullable LocalDate localDate, long days) Adds days to aLocalDate
.- Parameters:
localDate
- starting local datedays
- number of days to add- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting local date plus the specified number of days- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable LocalDateTime plus(@Nullable @Nullable LocalDateTime localDateTime, Period period) Adds a time period to aLocalDateTime
.- Parameters:
localDateTime
- starting local date timeperiod
- time period- Returns:
null
if either input isnull
; otherwise the starting local date time plus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable LocalDate plus(@Nullable @Nullable LocalDate localDate, Period period) Adds a time period to aLocalDate
.- Parameters:
localDate
- starting local dateperiod
- time period- Returns:
null
if either input isnull
; otherwise the starting local date plus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable Instant plus(@Nullable @Nullable Instant instant, long nanos) Adds nanoseconds to anInstant
.- Parameters:
instant
- starting instant valuenanos
- number of nanoseconds to add- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting instant plus the specified number of nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable ZonedDateTime plus(@Nullable @Nullable ZonedDateTime dateTime, long nanos) Adds nanoseconds to aZonedDateTime
.- Parameters:
dateTime
- starting zoned date time valuenanos
- number of nanoseconds to add- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting zoned date time plus the specified number of nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable Instant plus(@Nullable @Nullable Instant instant, @Nullable @Nullable Duration duration) Adds a time period to anInstant
.- Parameters:
instant
- starting instant valueduration
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting instant plus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable Instant plus(@Nullable @Nullable Instant instant, @Nullable @Nullable Period period) Adds a time period to anInstant
.- Parameters:
instant
- starting instant valueperiod
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting instant plus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable ZonedDateTime plus(@Nullable @Nullable ZonedDateTime dateTime, @Nullable @Nullable Duration duration) Adds a time period to aZonedDateTime
.- Parameters:
dateTime
- starting zoned date time valueduration
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting zoned date time plus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
@ScriptApi @Nullable public static @Nullable ZonedDateTime plus(@Nullable @Nullable ZonedDateTime dateTime, @Nullable @Nullable Period period) Adds a time period to aZonedDateTime
.- Parameters:
dateTime
- starting zoned date time valueperiod
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting zoned date time plus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
public static Duration plus(@Nullable @Nullable Duration duration1, @Nullable @Nullable Duration duration2) Adds two durations.- Parameters:
duration1
- first durationduration2
- second duration- Returns:
null
if either input isnull
; otherwise the sum of the two durations- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
plus
Adds two periods.- Parameters:
period1
- first periodperiod2
- second period- Returns:
null
if either input isnull
; otherwise the sum of the two periods- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minusDays
@ScriptApi @Nullable public static @Nullable LocalDateTime minusDays(@Nullable @Nullable LocalDateTime localDateTime, long days) Subtracts days from aLocalDate
.- Parameters:
localDateTime
- starting datedays
- number of days to subtract- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting local date time minus the specified number of days- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minusDays
@ScriptApi @Nullable public static @Nullable LocalDate minusDays(@Nullable @Nullable LocalDate localDate, long days) Subtracts days from aLocalDate
.- Parameters:
localDate
- starting local datedays
- number of days to subtract- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting local date minus the specified number of days- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable LocalDateTime minus(@Nullable @Nullable LocalDateTime localDateTime, Period period) Subtracts a time period from aLocalDateTime
.- Parameters:
localDateTime
- starting local date timeperiod
- time period- Returns:
null
if either input isnull
; otherwise the starting local date time minus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable LocalDate minus(@Nullable @Nullable LocalDate localDate, Period period) Subtracts a time period from aLocalDate
.- Parameters:
localDate
- starting local dateperiod
- time period- Returns:
null
if either input isnull
; otherwise the starting local date minus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable Instant minus(@Nullable @Nullable Instant instant, long nanos) Subtracts nanoseconds from anInstant
.- Parameters:
instant
- starting instant valuenanos
- number of nanoseconds to subtract- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting instant minus the specified number of nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable ZonedDateTime minus(@Nullable @Nullable ZonedDateTime dateTime, long nanos) Subtracts nanoseconds from aZonedDateTime
.- Parameters:
dateTime
- starting zoned date time valuenanos
- number of nanoseconds to subtract- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting zoned date time minus the specified number of nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable Instant minus(@Nullable @Nullable Instant instant, @Nullable @Nullable Duration duration) Subtracts a time period to anInstant
.- Parameters:
instant
- starting instant valueduration
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting instant minus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable Instant minus(@Nullable @Nullable Instant instant, @Nullable @Nullable Period period) Subtracts a time period to anInstant
.- Parameters:
instant
- starting instant valueperiod
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting instant minus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable ZonedDateTime minus(@Nullable @Nullable ZonedDateTime dateTime, @Nullable @Nullable Duration duration) Subtracts a time period to aZonedDateTime
.- Parameters:
dateTime
- starting zoned date time valueduration
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting zoned date time minus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi @Nullable public static @Nullable ZonedDateTime minus(@Nullable @Nullable ZonedDateTime dateTime, @Nullable @Nullable Period period) Subtracts a time period to aZonedDateTime
.- Parameters:
dateTime
- starting zoned date time valueperiod
- time period- Returns:
null
if either input isnull
orQueryConstants.NULL_LONG
; otherwise the starting zoned date time minus the specified time period- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi public static long minus(@Nullable @Nullable Instant instant1, @Nullable @Nullable Instant instant2) Subtract one instant from another and return the difference in nanoseconds.- Parameters:
instant1
- first instantinstant2
- second instant- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in instant1 and instant2 in nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
@ScriptApi public static long minus(@Nullable @Nullable ZonedDateTime dateTime1, @Nullable @Nullable ZonedDateTime dateTime2) Subtract one zoned date time from another and return the difference in nanoseconds.- Parameters:
dateTime1
- first zoned date timedateTime2
- second zoned date time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in dateTime1 and dateTime2 in nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
public static Duration minus(@Nullable @Nullable Duration duration1, @Nullable @Nullable Duration duration2) Subtracts two durations.- Parameters:
duration1
- first durationduration2
- second duration- Returns:
null
if either input isnull
; otherwise the difference of the two durations- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
minus
Subtracts two periods.- Parameters:
period1
- first periodperiod2
- second period- Returns:
null
if either input isnull
; otherwise the difference of the two periods- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
multiply
Multiply a duration by a scalar.- Parameters:
duration
- the duration to multiplyscalar
- the scalar to multiply by- Returns:
null
if either input isnull
; otherwise the duration multiplied by the scalar- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
multiply
Multiply a duration by a scalar.- Parameters:
duration
- the duration to multiplyscalar
- the scalar to multiply by- Returns:
null
if either input isnull
; otherwise the duration multiplied by the scalar- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
multiply
Multiply a period by a scalar.- Parameters:
period
- the period to multiplyscalar
- the scalar to multiply by- Returns:
null
if either input isnull
; otherwise the period multiplied by the scalar- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
multiply
Multiply a period by a scalar.- Parameters:
period
- the period to multiplyscalar
- the scalar to multiply by- Returns:
null
if either input isnull
; otherwise the period multiplied by the scalar- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
divide
Divide a duration by a scalar.- Parameters:
duration
- the duration to dividescalar
- the scalar to divide by- Returns:
null
if either input isnull
; otherwise the duration divide by the scalar- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffNanos
@ScriptApi public static long diffNanos(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in nanoseconds between two instant values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in start and end in nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffNanos
@ScriptApi public static long diffNanos(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in nanoseconds between two zoned date time values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in start and end in nanoseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffMicros
@ScriptApi public static long diffMicros(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in microseconds between two instant values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in start and end in microseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffMicros
@ScriptApi public static long diffMicros(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in microseconds between two zoned date time values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in start and end in microseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffMillis
@ScriptApi public static long diffMillis(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in milliseconds between two instant values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in start and end in milliseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffMillis
@ScriptApi public static long diffMillis(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in milliseconds between two zoned date time values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise the difference in start and end in milliseconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffSeconds
@ScriptApi public static double diffSeconds(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in seconds between two instant values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in seconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffSeconds
@ScriptApi public static double diffSeconds(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in seconds between two zoned date time values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in seconds- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffMinutes
@ScriptApi public static double diffMinutes(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in minutes between two instant values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in minutes- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffMinutes
@ScriptApi public static double diffMinutes(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in minutes between two zoned date time values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in minutes- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffDays
@ScriptApi public static double diffDays(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in days between two instant values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in days- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffDays
@ScriptApi public static double diffDays(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in days between two zoned date time values.- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in days- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffYears365
@ScriptApi public static double diffYears365(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in years between two instant values.Years are defined in terms of 365 day years.
- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in years- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffYears365
@ScriptApi public static double diffYears365(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in years between two zoned date time values.Years are defined in terms of 365 day years.
- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in years- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffYearsAvg
@ScriptApi public static double diffYearsAvg(@Nullable @Nullable Instant start, @Nullable @Nullable Instant end) Returns the difference in years between two instant values.Years are defined in terms of 365.2425 day years.
- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in years- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
diffYearsAvg
@ScriptApi public static double diffYearsAvg(@Nullable @Nullable ZonedDateTime start, @Nullable @Nullable ZonedDateTime end) Returns the difference in years between two zoned date time values.Years are defined in terms of 365.2425 day years.
- Parameters:
start
- start timeend
- end time- Returns:
QueryConstants.NULL_DOUBLE
if either input isnull
; otherwise the difference in start and end in years- Throws:
DateTimeUtils.DateTimeOverflowException
- if the datetime arithmetic overflows or underflows
-
isBefore
@ScriptApi public static boolean isBefore(@Nullable @Nullable Instant instant1, @Nullable @Nullable Instant instant2) Evaluates whether one instant value is before a second instant value.- Parameters:
instant1
- first instantinstant2
- second instant- Returns:
true
if instant1 is before instant2; otherwise,false
if either value isnull
or if instant2 is equal to or before instant1
-
isBefore
@ScriptApi public static boolean isBefore(@Nullable @Nullable ZonedDateTime dateTime1, @Nullable @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is before a second zoned date time value.- Parameters:
dateTime1
- first zoned date timedateTime2
- second zoned date time- Returns:
true
if dateTime1 is before dateTime2; otherwise,false
if either value isnull
or if dateTime2 is equal to or before dateTime1
-
isBeforeOrEqual
@ScriptApi public static boolean isBeforeOrEqual(@Nullable @Nullable Instant instant1, @Nullable @Nullable Instant instant2) Evaluates whether one instant value is before or equal to a second instant value.- Parameters:
instant1
- first instantinstant2
- second instant- Returns:
true
if instant1 is before or equal to instant2; otherwise,false
if either value isnull
or if instant2 is before instant1
-
isBeforeOrEqual
@ScriptApi public static boolean isBeforeOrEqual(@Nullable @Nullable ZonedDateTime dateTime1, @Nullable @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is before or equal to a second zoned date time value.- Parameters:
dateTime1
- first zoned date timedateTime2
- second zoned date time- Returns:
true
if dateTime1 is before or equal to dateTime2; otherwise,false
if either value isnull
or if dateTime2 is before dateTime1
-
isAfter
@ScriptApi public static boolean isAfter(@Nullable @Nullable Instant instant1, @Nullable @Nullable Instant instant2) Evaluates whether one instant value is after a second instant value.- Parameters:
instant1
- first instantinstant2
- second instant- Returns:
true
if instant1 is after instant2; otherwise,false
if either value isnull
or if instant2 is equal to or after instant1
-
isAfter
@ScriptApi public static boolean isAfter(@Nullable @Nullable ZonedDateTime dateTime1, @Nullable @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is after a second zoned date time value.- Parameters:
dateTime1
- first zoned date timedateTime2
- second zoned date time- Returns:
true
if dateTime1 is after dateTime2; otherwise,false
if either value isnull
or if dateTime2 is equal to or after dateTime1
-
isAfterOrEqual
@ScriptApi public static boolean isAfterOrEqual(@Nullable @Nullable Instant instant1, @Nullable @Nullable Instant instant2) Evaluates whether one instant value is after or equal to a second instant value.- Parameters:
instant1
- first instantinstant2
- second instant- Returns:
true
if instant1 is after or equal to instant2; otherwise,false
if either value isnull
or if instant2 is after instant1
-
isAfterOrEqual
@ScriptApi public static boolean isAfterOrEqual(@Nullable @Nullable ZonedDateTime dateTime1, @Nullable @Nullable ZonedDateTime dateTime2) Evaluates whether one zoned date time value is after or equal to a second zoned date time value.- Parameters:
dateTime1
- first zoned date timedateTime2
- second zoned date time- Returns:
true
if dateTime1 is after or equal to dateTime2; otherwise,false
if either value isnull
or if dateTime2 is after dateTime1
-
nanosOfMilli
Returns the number of nanoseconds that have elapsed since the top of the millisecond.- Parameters:
instant
- time- Returns:
QueryConstants.NULL_INT
if the input isnull
; otherwise, number of nanoseconds that have elapsed since the top of the millisecond
-
nanosOfMilli
Returns the number of nanoseconds that have elapsed since the top of the millisecond.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_INT
if the input isnull
; otherwise, number of nanoseconds that have elapsed since the top of the millisecond
-
microsOfMilli
Returns the number of microseconds that have elapsed since the top of the millisecond. Nanoseconds are rounded, not dropped -- '20:41:39.123456700' has 457 micros, not 456.- Parameters:
instant
- time- Returns:
QueryConstants.NULL_INT
if the input isnull
; otherwise, number of microseconds that have elapsed since the top of the millisecond
-
microsOfMilli
Returns the number of microseconds that have elapsed since the top of the millisecond. Nanoseconds are rounded, not dropped -- '20:41:39.123456700' has 457 micros, not 456.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_INT
if the input isnull
; otherwise, number of microseconds that have elapsed since the top of the millisecond
-
nanosOfSecond
@ScriptApi public static long nanosOfSecond(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the number of nanoseconds that have elapsed since the top of the second.- Parameters:
instant
- timetimeZone
- time zone- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise, number of nanoseconds that have elapsed since the top of the second
-
nanosOfSecond
Returns the number of nanoseconds that have elapsed since the top of the second.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise, number of nanoseconds that have elapsed since the top of the second
-
microsOfSecond
@ScriptApi public static long microsOfSecond(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the number of microseconds that have elapsed since the top of the second.- Parameters:
instant
- timetimeZone
- time zone- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise, number of microseconds that have elapsed since the top of the second
-
microsOfSecond
Returns the number of microseconds that have elapsed since the top of the second.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise, number of microseconds that have elapsed since the top of the second
-
millisOfSecond
@ScriptApi public static int millisOfSecond(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the number of milliseconds that have elapsed since the top of the second.- Parameters:
instant
- timetimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of milliseconds that have elapsed since the top of the second
-
millisOfSecond
Returns the number of milliseconds that have elapsed since the top of the second.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of milliseconds that have elapsed since the top of the second
-
secondOfMinute
@ScriptApi public static int secondOfMinute(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the number of seconds that have elapsed since the top of the minute.- Parameters:
instant
- timetimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of seconds that have elapsed since the top of the minute
-
secondOfMinute
Returns the number of seconds that have elapsed since the top of the minute.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of seconds that have elapsed since the top of the minute
-
minuteOfHour
@ScriptApi public static int minuteOfHour(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the number of minutes that have elapsed since the top of the hour.- Parameters:
instant
- timetimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of minutes that have elapsed since the top of the hour
-
minuteOfHour
Returns the number of minutes that have elapsed since the top of the hour.- Parameters:
dateTime
- time- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of minutes that have elapsed since the top of the hour
-
nanosOfDay
@ScriptApi public static long nanosOfDay(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of nanoseconds that have elapsed since the start of the day.- Parameters:
instant
- timetimeZone
- time zoneasLocalTime
- Iftrue
, returns the number of nanos from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of nanos from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise, number of nanoseconds that have elapsed since the start of the day
-
nanosOfDay
@ScriptApi public static long nanosOfDay(@Nullable @Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of nanoseconds that have elapsed since the start of the day.- Parameters:
dateTime
- timeasLocalTime
- Iftrue
, returns the number of nanos from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of nanos from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_LONG
if either input isnull
; otherwise, number of nanoseconds that have elapsed since the start of the day
-
nanosOfDay
Returns the number of nanoseconds that have elapsed since the start of the day.- Parameters:
localDateTime
- local date time- Returns:
QueryConstants.NULL_LONG
if input isnull
; otherwise, number of nanoseconds that have elapsed since the start of the day
-
nanosOfDay
Returns the number of nanoseconds that have elapsed since the start of the day.- Parameters:
localTime
- local time- Returns:
QueryConstants.NULL_LONG
if input isnull
; otherwise, number of nanoseconds that have elapsed since the start of the day
-
millisOfDay
@ScriptApi public static int millisOfDay(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of milliseconds that have elapsed since the start of the day.- Parameters:
instant
- timetimeZone
- time zoneasLocalTime
- Iftrue
, returns the number of milliseconds from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of milliseconds from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of milliseconds that have elapsed since the start of the day
-
millisOfDay
@ScriptApi public static int millisOfDay(@Nullable @Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of milliseconds that have elapsed since the start of the day.- Parameters:
dateTime
- timeasLocalTime
- Iftrue
, returns the number of milliseconds from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of milliseconds from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of milliseconds that have elapsed since the start of the day
-
millisOfDay
Returns the number of milliseconds that have elapsed since the start of the day.- Parameters:
localDateTime
- local date time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of milliseconds that have elapsed since the start of the day
-
millisOfDay
Returns the number of milliseconds that have elapsed since the start of the day.- Parameters:
localTime
- local time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of milliseconds that have elapsed since the start of the day
-
secondOfDay
@ScriptApi public static int secondOfDay(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of seconds that have elapsed since the start of the day.- Parameters:
instant
- timetimeZone
- time zoneasLocalTime
- Iftrue
, returns the number of nanos from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of nanos from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of seconds that have elapsed since the start of the day
-
secondOfDay
@ScriptApi public static int secondOfDay(@Nullable @Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of seconds that have elapsed since the start of the day.- Parameters:
dateTime
- timeasLocalTime
- Iftrue
, returns the number of seconds from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of seconds from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of seconds that have elapsed since the start of the day
-
secondOfDay
Returns the number of seconds that have elapsed since the start of the day.- Parameters:
localDateTime
- local date time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of seconds that have elapsed since the start of the day
-
secondOfDay
Returns the number of seconds that have elapsed since the start of the day.- Parameters:
localTime
- local time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of seconds that have elapsed since the start of the day
-
minuteOfDay
@ScriptApi public static int minuteOfDay(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of minutes that have elapsed since the start of the day.- Parameters:
instant
- timetimeZone
- time zoneasLocalTime
- Iftrue
, returns the number of minutes from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of minutes from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same as if asLocalTime is false.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of minutes that have elapsed since the start of the day
-
minuteOfDay
@ScriptApi public static int minuteOfDay(@Nullable @Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of minutes that have elapsed since the start of the day.- Parameters:
dateTime
- timeasLocalTime
- Iftrue
, returns the number of minutes from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of minutes from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of minutes that have elapsed since the start of the day
-
minuteOfDay
Returns the number of minutes that have elapsed since the start of the day.- Parameters:
localDateTime
- local date time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of minutes that have elapsed since the start of the day
-
minuteOfDay
Returns the number of minutes that have elapsed since the start of the day.- Parameters:
localTime
- local time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of minutes that have elapsed since the start of the day
-
hourOfDay
@ScriptApi public static int hourOfDay(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone, boolean asLocalTime) Returns the number of hours that have elapsed since the start of the day.- Parameters:
instant
- timetimeZone
- time zoneasLocalTime
- Iftrue
, returns the number of hours from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of hours from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of hours that have elapsed since the start of the day
-
hourOfDay
@ScriptApi public static int hourOfDay(@Nullable @Nullable ZonedDateTime dateTime, boolean asLocalTime) Returns the number of hours that have elapsed since the start of the day.- Parameters:
dateTime
- timeasLocalTime
- Iftrue
, returns the number of hours from the start of the day according to the local time. In this case, 9:30AM always returns the same value. Iffalse
, returns the number of hours from the start of the day. On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards. On non DST days, the result is the same regardless of the value ofasLocalTime
.- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, number of hours that have elapsed since the start of the day
-
hourOfDay
Returns the number of hours that have elapsed since the start of the day.- Parameters:
localDateTime
- local date time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of hours that have elapsed since the start of the day
-
hourOfDay
Returns the number of hours that have elapsed since the start of the day.- Parameters:
localTime
- local time- Returns:
QueryConstants.NULL_INT
if input isnull
; otherwise, number of hours that have elapsed since the start of the day
-
dayOfWeek
Returns athe day of the week for aZonedDateTime
.- Parameters:
localDateTime
- local date time to find the day of the week of- Returns:
null
iflocalDateTime
isnull
; otherwise, the day of the week
-
dayOfWeek
Returns the day of the week for aLocalDate
.- Parameters:
localDate
- local date to find the day of the week of- Returns:
null
iflocalDate
isnull
; otherwise, the day of the week
-
dayOfWeek
@ScriptApi public static DayOfWeek dayOfWeek(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the day of the week for anInstant
in the specified time zone.- Parameters:
instant
- time to find the day of the week oftimeZone
- time zone- Returns:
null
if either input isnull
; otherwise, the day of the week
-
dayOfWeek
Returns the day of the week for aZonedDateTime
in the specified time zone.- Parameters:
dateTime
- time to find the day of the week of- Returns:
null
if either input isnull
; otherwise, the day of the week
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for aLocalDateTime
, with 1 being Monday and 7 being Sunday.- Parameters:
localDateTime
- local date time to find the day of the week of- Returns:
QueryConstants.NULL_INT
iflocalDateTime
isnull
; otherwise, the day of the week
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for aLocalDate
, with 1 being Monday and 7 being Sunday.- Parameters:
localDate
- local date to find the day of the week of- Returns:
QueryConstants.NULL_INT
iflocalDate
isnull
; otherwise, the day of the week
-
dayOfWeekValue
@ScriptApi public static int dayOfWeekValue(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns a 1-based int value of the day of the week for anInstant
in the specified time zone, with 1 being Monday and 7 being Sunday.- Parameters:
instant
- time to find the day of the week oftimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the day of the week
-
dayOfWeekValue
Returns a 1-based int value of the day of the week for aZonedDateTime
in the specified time zone, with 1 being Monday and 7 being Sunday.- Parameters:
dateTime
- time to find the day of the week of- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the day of the week
-
dayOfMonth
Returns a 1-based int value of the day of the month for aLocalDateTime
. The first day of the month returns 1, the second day returns 2, etc.- Parameters:
localDateTime
- local date time to find the day of the month of- Returns:
- A
QueryConstants.NULL_INT
iflocalDateTime
isnull
; otherwise, the day of the month
-
dayOfMonth
Returns a 1-based int value of the day of the month for aLocalDate
. The first day of the month returns 1, the second day returns 2, etc.- Parameters:
localDate
- local date to find the day of the month of- Returns:
- A
QueryConstants.NULL_INT
iflocalDate
isnull
; otherwise, the day of the month
-
dayOfMonth
@ScriptApi public static int dayOfMonth(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns a 1-based int value of the day of the month for anInstant
and specified time zone. The first day of the month returns 1, the second day returns 2, etc.- Parameters:
instant
- time to find the day of the month oftimeZone
- time zone- Returns:
- A
QueryConstants.NULL_INT
if either input isnull
; otherwise, the day of the month
-
dayOfMonth
Returns a 1-based int value of the day of the month for aZonedDateTime
and specified time zone. The first day of the month returns 1, the second day returns 2, etc.- Parameters:
dateTime
- time to find the day of the month of- Returns:
- A
QueryConstants.NULL_INT
if either input isnull
; otherwise, the day of the month
-
dayOfYear
Returns a 1-based int value of the day of the year (Julian date) for aLocalDateTime
. The first day of the year returns 1, the second day returns 2, etc.- Parameters:
localDateTime
- local date time to find the day of the year of- Returns:
QueryConstants.NULL_INT
iflocalDateTime
isnull
; otherwise, the day of the year
-
dayOfYear
Returns a 1-based int value of the day of the year (Julian date) for aLocalDate
. The first day of the year returns 1, the second day returns 2, etc.- Parameters:
localDate
- local date to find the day of the year of- Returns:
QueryConstants.NULL_INT
iflocalDate
isnull
; otherwise, the day of the year
-
dayOfYear
@ScriptApi public static int dayOfYear(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns a 1-based int value of the day of the year (Julian date) for anInstant
in the specified time zone. The first day of the year returns 1, the second day returns 2, etc.- Parameters:
instant
- time to find the day of the year oftimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the day of the year
-
dayOfYear
Returns a 1-based int value of the day of the year (Julian date) for aZonedDateTime
in the specified time zone. The first day of the year returns 1, the second day returns 2, etc.- Parameters:
dateTime
- time to find the day of the year of- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the day of the year
-
monthOfYear
Returns a 1-based int value of the month of the year (Julian date) for aLocalDateTime
. January is 1, February is 2, etc.- Parameters:
localDateTime
- local date time to find the month of the year of- Returns:
QueryConstants.NULL_INT
iflocalDateTime
isnull
; otherwise, the month of the year
-
monthOfYear
Returns a 1-based int value of the month of the year (Julian date) for aLocalDate
. January is 1, February is 2, etc.- Parameters:
localDate
- local date to find the month of the year of- Returns:
QueryConstants.NULL_INT
iflocalDate
isnull
; otherwise, the month of the year
-
monthOfYear
@ScriptApi public static int monthOfYear(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns a 1-based int value of the month of the year (Julian date) for anInstant
in the specified time zone. January is 1, February is 2, etc.- Parameters:
instant
- time to find the month of the year oftimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the month of the year
-
monthOfYear
Returns a 1-based int value of the month of the year (Julian date) for aZonedDateTime
in the specified time zone. January is 1, February is 2, etc.- Parameters:
dateTime
- time to find the month of the year of- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the month of the year
-
year
Returns the year for aLocalDateTime
.- Parameters:
localDateTime
- local date to find the year of- Returns:
QueryConstants.NULL_INT
iflocalDateTime
isnull
; otherwise, the year
-
year
Returns the year for aLocalDate
.- Parameters:
localDate
- local date to find the year of- Returns:
QueryConstants.NULL_INT
iflocalDate
isnull
; otherwise, the year
-
year
@ScriptApi public static int year(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the year for anInstant
in the specified time zone.- Parameters:
instant
- time to find the year oftimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the year
-
year
Returns the year for aZonedDateTime
in the specified time zone.- Parameters:
dateTime
- time to find the year of- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the year
-
yearOfCentury
Returns the year of the century (two-digit year) for aLocalDateTime
.- Parameters:
localDateTime
- local date time to find the year of- Returns:
QueryConstants.NULL_INT
iflocalDateTime
isnull
; otherwise, the year of the century (two-digit year)
-
yearOfCentury
Returns the year of the century (two-digit year) for aLocalDate
.- Parameters:
localDate
- local date to find the year of- Returns:
QueryConstants.NULL_INT
iflocalDate
isnull
; otherwise, the year of the century (two-digit year)
-
yearOfCentury
@ScriptApi public static int yearOfCentury(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns the year of the century (two-digit year) for anInstant
in the specified time zone.- Parameters:
instant
- time to find the year oftimeZone
- time zone- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the year of the century (two-digit year)
-
yearOfCentury
Returns the year of the century (two-digit year) for aZonedDateTime
in the specified time zone.- Parameters:
dateTime
- time to find the day of the month of- Returns:
QueryConstants.NULL_INT
if either input isnull
; otherwise, the year of the century (two-digit year)
-
atMidnight
@ScriptApi @Nullable public static @Nullable ZonedDateTime atMidnight(@Nullable @Nullable LocalDateTime localDateTime, @Nullable @Nullable ZoneId timeZone) Returns aZonedDateTime
for the prior midnight in the specified time zone.- Parameters:
localDateTime
- local date time to compute the prior midnight fortimeZone
- time zone- Returns:
null
if either input isnull
; otherwise aZonedDateTime
representing the prior midnight in the specified time zone
-
atMidnight
@ScriptApi @Nullable public static @Nullable ZonedDateTime atMidnight(@Nullable @Nullable LocalDate localDate, @Nullable @Nullable ZoneId timeZone) Returns aZonedDateTime
for the prior midnight in the specified time zone.- Parameters:
localDate
- local date to compute the prior midnight fortimeZone
- time zone- Returns:
null
if either input isnull
; otherwise aZonedDateTime
representing the prior midnight in the specified time zone
-
atMidnight
@ScriptApi @Nullable public static @Nullable Instant atMidnight(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns anInstant
for the prior midnight in the specified time zone.- Parameters:
instant
- time to compute the prior midnight fortimeZone
- time zone- Returns:
null
if either input isnull
; otherwise anInstant
representing the prior midnight in the specified time zone
-
atMidnight
@ScriptApi @Nullable public static @Nullable ZonedDateTime atMidnight(@Nullable @Nullable ZonedDateTime dateTime) Returns aZonedDateTime
for the prior midnight in the specified time zone.- Parameters:
dateTime
- time to compute the prior midnight for- Returns:
null
if either input isnull
; otherwise aZonedDateTime
representing the prior midnight in the specified time zone
-
lowerBin
@ScriptApi @Nullable public static @Nullable Instant lowerBin(@Nullable @Nullable Instant instant, long intervalNanos) Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the instant value for the start of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanoseconds- Returns:
null
if either input isnull
; otherwise, anInstant
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable Instant lowerBin(@Nullable @Nullable Instant instant, Duration interval) Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the instant value for the start of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowinterval
- size of the window- Returns:
null
if either input isnull
; otherwise, anInstant
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime lowerBin(@Nullable @Nullable ZonedDateTime dateTime, long intervalNanos) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the zoned date time value for the start of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanoseconds- Returns:
null
if either input isnull
; otherwise, aZonedDateTime
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime lowerBin(@Nullable @Nullable ZonedDateTime dateTime, Duration interval) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the zoned date time value for the start of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowinterval
- size of the window- Returns:
null
if either input isnull
; otherwise, aZonedDateTime
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable Instant lowerBin(@Nullable @Nullable Instant instant, long intervalNanos, long offset) Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the instant value for the start of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanosecondsoffset
- The window start offset in nanoseconds. For example, a value of MINUTE would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, anInstant
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable Instant lowerBin(@Nullable @Nullable Instant instant, Duration interval, Duration offset) Returns anInstant
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the instant value for the start of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowinterval
- size of the windowoffset
- The window start offset. For example, a value of 'PT1m' would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, anInstant
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime lowerBin(@Nullable @Nullable ZonedDateTime dateTime, long intervalNanos, long offset) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the zoned date time value for the start of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanosecondsoffset
- The window start offset in nanoseconds. For example, a value of MINUTE would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, aZonedDateTime
representing the start of the window
-
lowerBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime lowerBin(@Nullable @Nullable ZonedDateTime dateTime, Duration interval, Duration offset) Returns aZonedDateTime
value, which is at the starting (lower) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
intervalNanos value would return the zoned date time value for the start of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowinterval
- size of the windowoffset
- The window start offset. For example, a value of MINUTE would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, aZonedDateTime
representing the start of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable Instant upperBin(@Nullable @Nullable Instant instant, long intervalNanos) Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the instant value for the end of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanoseconds- Returns:
null
if either input isnull
; otherwise, anInstant
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable Instant upperBin(@Nullable @Nullable Instant instant, Duration interval) Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the instant value for the end of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowinterval
- size of the window- Returns:
null
if either input isnull
; otherwise, anInstant
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime upperBin(@Nullable @Nullable ZonedDateTime dateTime, long intervalNanos) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the zoned date time value for the end of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanoseconds- Returns:
null
if either input isnull
; otherwise, aZonedDateTime
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime upperBin(@Nullable @Nullable ZonedDateTime dateTime, Duration interval) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the zoned date time value for the end of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowinterval
- size of the window- Returns:
null
if either input isnull
; otherwise, aZonedDateTime
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable Instant upperBin(@Nullable @Nullable Instant instant, long intervalNanos, long offset) Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the instant value for the end of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanosecondsoffset
- The window start offset in nanoseconds. For example, a value of MINUTE would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, anInstant
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable Instant upperBin(@Nullable @Nullable Instant instant, Duration interval, Duration offset) Returns anInstant
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the instant value for the end of the five-minute window that contains the input instant.- Parameters:
instant
- instant for which to evaluate the start of the containing windowinterval
- size of the windowoffset
- The window start offset. For example, a value of 'PT1m' would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, anInstant
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime upperBin(@Nullable @Nullable ZonedDateTime dateTime, long intervalNanos, long offset) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteintervalNanos
value would return the zoned date time value for the end of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowintervalNanos
- size of the window in nanosecondsoffset
- The window start offset in nanoseconds. For example, a value of MINUTE would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, aZonedDateTime
representing the end of the window
-
upperBin
@ScriptApi @Nullable public static @Nullable ZonedDateTime upperBin(@Nullable @Nullable ZonedDateTime dateTime, Duration interval, Duration offset) Returns aZonedDateTime
value, which is at the ending (upper) end of a time range defined by the interval nanoseconds. For example, a five-minuteinterval
value would return the zoned date time value for the end of the five-minute window that contains the input zoned date time.- Parameters:
dateTime
- zoned date time for which to evaluate the start of the containing windowinterval
- size of the windowoffset
- The window start offset. For example, a value of 'PT1m' would offset all windows by one minute.- Returns:
null
if any input isnull
; otherwise, aZonedDateTime
representing the end of the window
-
formatDurationNanos
Returns a nanosecond duration formatted as a "[-]PThhh:mm:ss.nnnnnnnnn" string.- Parameters:
nanos
- nanoseconds, ornull
if the input isQueryConstants.NULL_LONG
- Returns:
- the nanosecond duration formatted as a "[-]PThhh:mm:ss.nnnnnnnnn" string
-
formatDateTime
@ScriptApi @Nullable public static @Nullable String formatDateTime(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns anInstant
formatted as a "yyyy-MM-ddThh:mm:ss.SSSSSSSSS TZ" string.- Parameters:
instant
- time to format as a stringtimeZone
- time zone to use when formatting the string.- Returns:
null
if either input isnull
; otherwise, the time formatted as a "yyyy-MM-ddThh:mm:ss.nnnnnnnnn TZ" string
-
formatDateTime
@ScriptApi @Nullable public static @Nullable String formatDateTime(@Nullable @Nullable ZonedDateTime dateTime) Returns aZonedDateTime
formatted as a "yyyy-MM-ddThh:mm:ss.SSSSSSSSS TZ" string.- Parameters:
dateTime
- time to format as a string- Returns:
null
if either input isnull
; otherwise, the time formatted as a "yyyy-MM-ddThh:mm:ss.nnnnnnnnn TZ" string
-
formatDate
@ScriptApi @Nullable public static @Nullable String formatDate(@Nullable @Nullable Instant instant, @Nullable @Nullable ZoneId timeZone) Returns anInstant
formatted as a "yyyy-MM-dd" string.- Parameters:
instant
- time to format as a stringtimeZone
- time zone to use when formatting the string.- Returns:
null
if either input isnull
; otherwise, the time formatted as a "yyyy-MM-dd" string
-
formatDate
@ScriptApi @Nullable public static @Nullable String formatDate(@Nullable @Nullable ZonedDateTime dateTime) Returns aZonedDateTime
formatted as a "yyyy-MM-dd" string.- Parameters:
dateTime
- time to format as a string- Returns:
null
if either input isnull
; otherwise, the time formatted as a "yyyy-MM-dd" string
-
formatDate
@ScriptApi @Nullable public static @Nullable String formatDate(@Nullable @Nullable LocalDateTime localDateTime) Returns aLocalDateTime
formatted as a "yyyy-MM-dd" string.- Parameters:
localDateTime
- local date time to format as a string- Returns:
null
if either input isnull
; otherwise, the time formatted as a "yyyy-MM-dd" string
-
formatDate
@ScriptApi @Nullable public static @Nullable String formatDate(@Nullable @Nullable LocalDate localDate) Returns aLocalDate
formatted as a "yyyy-MM-dd" string.- Parameters:
localDate
- local date to format as a string- Returns:
null
if either input isnull
; otherwise, the time formatted as a "yyyy-MM-dd" string
-
parseTimeZone
Parses the string argument as a time zone.- Parameters:
s
- string to be converted- Returns:
- a
ZoneId
represented by the input string - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be converted- See Also:
-
parseTimeZoneQuiet
@ScriptApi @Nullable public static @Nullable ZoneId parseTimeZoneQuiet(@Nullable @Nullable String s) Parses the string argument as a time zone.- Parameters:
s
- string to be converted- Returns:
- a
ZoneId
represented by the input string, ornull
if the string can not be parsed - See Also:
-
parseDurationNanos
Parses the string argument as a time duration in nanoseconds.Time duration strings can be formatted as
[-]PT[-]hh:mm:[ss.nnnnnnnnn]
or as a duration string formatted as[-]PnDTnHnMn.nS
.- Parameters:
s
- string to be converted- Returns:
- the number of nanoseconds represented by the string
- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parseDurationNanosQuiet
Parses the string argument as a time duration in nanoseconds.Time duration strings can be formatted as
[-]PT[-]hh:mm:[ss.nnnnnnnnn]
or as a duration string formatted as[-]PnDTnHnMn.nS
.- Parameters:
s
- string to be converted- Returns:
- the number of nanoseconds represented by the string, or
QueryConstants.NULL_LONG
if the string cannot be parsed - See Also:
-
parsePeriod
Parses the string argument as a period, which is a unit of time in terms of calendar time (days, weeks, months, years, etc.).Period strings are formatted according to the ISO-8601 duration format as
PnYnMnD
andPnW
, where the coefficients can be positive or negative. Zero coefficients can be omitted. Optionally, the string can begin with a negative sign.Examples:
"P2Y" -- Period.ofYears(2) "P3M" -- Period.ofMonths(3) "P4W" -- Period.ofWeeks(4) "P5D" -- Period.ofDays(5) "P1Y2M3D" -- Period.of(1, 2, 3) "P1Y2M3W4D" -- Period.of(1, 2, 25) "P-1Y2M" -- Period.of(-1, 2, 0) "-P1Y2M" -- Period.of(-1, -2, 0)
- Parameters:
s
- period string- Returns:
- the period
- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parsePeriodQuiet
Parses the string argument as a period, which is a unit of time in terms of calendar time (days, weeks, months, years, etc.).Period strings are formatted according to the ISO-8601 duration format as
PnYnMnD
andPnW
, where the coefficients can be positive or negative. Zero coefficients can be omitted. Optionally, the string can begin with a negative sign.Examples:
"P2Y" -- Period.ofYears(2) "P3M" -- Period.ofMonths(3) "P4W" -- Period.ofWeeks(4) "P5D" -- Period.ofDays(5) "P1Y2M3D" -- Period.of(1, 2, 3) "P1Y2M3W4D" -- Period.of(1, 2, 25) "P-1Y2M" -- Period.of(-1, 2, 0) "-P1Y2M" -- Period.of(-1, -2, 0)
- Parameters:
s
- period string- Returns:
- the period, or
null
if the string can not be parsed - See Also:
-
parseDuration
Parses the string argument as a duration, which is a unit of time in terms of clock time (24-hour days, hours, minutes, seconds, and nanoseconds).Duration strings are formatted according to the ISO-8601 duration format as
[-]PnDTnHnMn.nS
, where the coefficients can be positive or negative. Zero coefficients can be omitted. Optionally, the string can begin with a negative sign.Examples:
"PT20.345S" -- parses as "20.345 seconds" "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds) "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds) "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds) "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes" "PT-6H3M" -- parses as "-6 hours and +3 minutes" "-PT6H3M" -- parses as "-6 hours and -3 minutes" "-PT-6H+3M" -- parses as "+6 hours and -3 minutes"
- Parameters:
s
- duration string- Returns:
- the duration
- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parseDurationQuiet
@ScriptApi @Nullable public static @Nullable Duration parseDurationQuiet(@Nullable @Nullable String s) Parses the string argument as a duration, which is a unit of time in terms of clock time (24-hour days, hours, minutes, seconds, and nanoseconds).Duration strings are formatted according to the ISO-8601 duration format as
[-]PnDTnHnMn.nS
, where the coefficients can be positive or negative. Zero coefficients can be omitted. Optionally, the string can begin with a negative sign.Examples:
"PT20.345S" -- parses as "20.345 seconds" "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds) "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds) "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds) "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes" "PT-6H3M" -- parses as "-6 hours and +3 minutes" "-PT6H3M" -- parses as "-6 hours and -3 minutes" "-PT-6H+3M" -- parses as "+6 hours and -3 minutes"
- Parameters:
s
- duration string- Returns:
- the duration, or
null
if the string can not be parsed - See Also:
-
parseEpochNanos
Parses the string argument as nanoseconds since the Epoch.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ
and others. Additionally, date time strings can be integer values that are nanoseconds, milliseconds, or seconds from the Epoch. Expected date ranges are used to infer the units.- Parameters:
s
- date time string- Returns:
- a long number of nanoseconds since the Epoch, matching the instant represented by the input string
- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parseEpochNanosQuiet
Parses the string argument as a nanoseconds since the Epoch.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ
and others. Additionally, date time strings can be integer values that are nanoseconds, milliseconds, or seconds from the Epoch. Expected date ranges are used to infer the units.- Parameters:
s
- date time string- Returns:
- a long number of nanoseconds since the Epoch, matching the instant represented by the input string, or
null
if the string can not be parsed - See Also:
-
parseInstant
Parses the string argument as anInstant
.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ
and others. Additionally, date time strings can be integer values that are nanoseconds, milliseconds, or seconds from the Epoch. Expected date ranges are used to infer the units.- Parameters:
s
- date time string- Returns:
- an
Instant
represented by the input string - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parseInstantQuiet
@ScriptApi @Nullable public static @Nullable Instant parseInstantQuiet(@Nullable @Nullable String s) Parses the string argument as anInstant
.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ
and others. Additionally, date time strings can be integer values that are nanoseconds, milliseconds, or seconds from the Epoch. Expected date ranges are used to infer the units.- Parameters:
s
- date time string- Returns:
- an
Instant
represented by the input string, ornull
if the string can not be parsed - See Also:
-
parseLocalDateTime
@ScriptApi @NotNull public static @NotNull LocalDateTime parseLocalDateTime(@NotNull @NotNull String s) Parses the string argument as aLocalDateTime
.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS]
and others.- Parameters:
s
- date time string- Returns:
- a
LocalDateTime
represented by the input string - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed
-
parseLocalDateTimeQuiet
@ScriptApi @Nullable public static @Nullable LocalDateTime parseLocalDateTimeQuiet(@Nullable @Nullable String s) Parses the string argument as aLocalDateTime
.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS]
and others.- Parameters:
s
- date time string- Returns:
- a
LocalDateTime
represented by the input string, ornull
if the string can not be parsed
-
parseZonedDateTime
@ScriptApi @NotNull public static @NotNull ZonedDateTime parseZonedDateTime(@NotNull @NotNull String s) Parses the string argument as aZonedDateTime
.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ
and others.- Parameters:
s
- date time string- Returns:
- a
ZonedDateTime
represented by the input string - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parseZonedDateTimeQuiet
@ScriptApi @Nullable public static @Nullable ZonedDateTime parseZonedDateTimeQuiet(@Nullable @Nullable String s) Parses the string argument as aZonedDateTime
.Date time strings are formatted according to the ISO 8601 date time format
yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ
and others.- Parameters:
s
- date time string- Returns:
- a
ZonedDateTime
represented by the input string, ornull
if the string can not be parsed - See Also:
-
parseTimePrecision
@ScriptApi @NotNull public static @NotNull ChronoField parseTimePrecision(@NotNull @NotNull String s) Returns aChronoField
indicating the level of precision in a time, datetime, or period nanos string.- Parameters:
s
- time string- Returns:
ChronoField
for the finest units in the string (e.g. "10:00:00" would yield SecondOfMinute)- Throws:
RuntimeException
- if the string cannot be parsed
-
parseTimePrecisionQuiet
@ScriptApi @Nullable public static @Nullable ChronoField parseTimePrecisionQuiet(@Nullable @Nullable String s) Returns aChronoField
indicating the level of precision in a time or datetime string.- Parameters:
s
- time string- Returns:
null
if the time string cannot be parsed; otherwise, aChronoField
for the finest units in the string (e.g. "10:00:00" would yield SecondOfMinute)- Throws:
RuntimeException
- if the string cannot be parsed
-
parseLocalDate
Parses the string argument as a local date, which is a date without a time or time zone.Date strings are formatted according to the ISO 8601 date time format as
YYYY-MM-DD
.- Parameters:
s
- date string- Returns:
- local date parsed according to the default date style
- Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be parsed- See Also:
-
parseLocalDateQuiet
@ScriptApi @Nullable public static @Nullable LocalDate parseLocalDateQuiet(@Nullable @Nullable String s) Parses the string argument as a local date, which is a date without a time or time zone.Date strings are formatted according to the ISO 8601 date time format as
YYYY-MM-DD
.- Parameters:
s
- date string- Returns:
- local date parsed according to the default date style, or
null
if the string can not be parsed - See Also:
-
parseLocalTime
Parses the string argument as a local time, which is the time that would be read from a clock and does not have a date or timezone.Local time strings can be formatted as
hh:mm:ss[.nnnnnnnnn]
.- Parameters:
s
- string to be converted- Returns:
- a
LocalTime
represented by the input string. - Throws:
DateTimeUtils.DateTimeParseException
- if the string cannot be converted, otherwise aLocalTime
from the parsed string
-
parseLocalTimeQuiet
@ScriptApi @Nullable public static @Nullable LocalTime parseLocalTimeQuiet(@Nullable @Nullable String s) Parses the string argument as a local time, which is the time that would be read from a clock and does not have a date or timezone.Local time strings can be formatted as
hh:mm:ss[.nnnnnnnnn]
.- Parameters:
s
- string to be converted- Returns:
- a
LocalTime
represented by the input string, ornull
if the string can not be parsed
-