java-time.api
+
(+ o & os)
Adds all of the os
to the time entity o
. +
is not commutative, the first argument is always the entity which will accumulate the rest of the arguments.
+
(+ o & os)
Adds all of the os
to the time entity o
. +
is not commutative, the first argument is always the entity which will accumulate the rest of the arguments.
(j/+ (j/local-date 2015) (j/years 1))
=> <java.time.LocalDate "2016-01-01">
--
(- o & os)
Subtracts all of the os
from the time entity o
(j/- (j/local-date 2015) (j/years 1))
=> <java.time.LocalDate "2014-01-01">
-<
(< x)
(< x y)
(< x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <
), otherwise false
.
<
(< x)
(< x y)
(< x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <
), otherwise false
.
(j/< (local-date 2009) (local-date 2010) (local-date 2011))
=> true
@@ -17,7 +17,7 @@
(instant 99999999))
=> true
-<=
(<= x)
(<= x y)
(<= x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <=
), otherwise false
.
<=
(<= x)
(<= x y)
(<= x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <=
), otherwise false
.
(j/<= (local-date 2009) (local-date 2010) (local-date 2011))
;=> true
@@ -25,10 +25,10 @@
(instant 99999999))
;=> true
-=
(= x)
(= x y)
(= x y & more)
Returns true if all time entities represent the same time, otherwise false.
+=
(= x)
(= x y)
(= x y & more)
Returns true if all time entities represent the same time, otherwise false.
j/=
is not commutative, the first argument is always the entity which will accumulate the rest of the arguments.
e.g., (j/= (j/day-of-week :thursday) :thursday) => true
->
(> x)
(> x y)
(> x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >
), otherwise false
.
>
(> x)
(> x y)
(> x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >
), otherwise false
.
(j/> (local-date 2011) (local-date 2010) (local-date 2009))
=> true
@@ -36,7 +36,7 @@
(interval (instant 10000) (instant 1000000)))
=> true
->=
(>= x)
(>= x y)
(>= x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >=
), otherwise false
.
>=
(>= x)
(>= x y)
(>= x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >=
), otherwise false
.
(j/>= (local-date 2011) (local-date 2010) (local-date 2009))
;=> true
@@ -44,10 +44,10 @@
(interval (instant 10000) (instant 1000000)))
;=> true
-adjust
(adjust entity adjuster & args)
Adjusts the temporal entity
using the provided adjuster
with optional args
.
adjust
(adjust entity adjuster & args)
Adjusts the temporal entity
using the provided adjuster
with optional args
.
The adjuster should either be a keyword which resolves to one of the predefined adjusters (see java-time.repl/show-adjusters) an instance of TemporalAdjuster
or a function which returns another temporal entity when applied to the given one:
(adjust (local-date 2015 1 1) :next-working-day)
=> #<LocalDate 2015-1-2>
@@ -58,9 +58,9 @@
(adjust (local-date 2015 1 1) plus (days 1))
=> #<LocalDate 2015-1-2>
-advance-clock!
(advance-clock! clock amount)
Advances the clock
by the given time amount
.
advance-clock!
(advance-clock! clock amount)
Advances the clock
by the given time amount
.
This mutates the mock clock.
-after?
(after? x)
(after? x y)
(after? x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >
), otherwise false
.
after?
(after? x)
(after? x y)
(after? x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >
), otherwise false
.
(after? (local-date 2011) (local-date 2010) (local-date 2009))
=> true
@@ -68,24 +68,24 @@
(interval (instant 10000) (instant 1000000)))
=> true
-am-pm
(am-pm)
(am-pm v)
(am-pm fmt arg)
Returns the AmPm
for the given keyword name (:am
or :pm
), ordinal or entity. Current AM/PM if no arguments given.
as
(as o k)
(as o k1 k2)
(as o k1 k2 & ks)
Values of property/unit identified by keys/objects ks
of the temporal entity o
, e.g.
am-pm
(am-pm)
(am-pm v)
(am-pm fmt arg)
Returns the AmPm
for the given keyword name (:am
or :pm
), ordinal or entity. Current AM/PM if no arguments given.
as
(as o k)
(as o k1 k2)
(as o k1 k2 & ks)
Values of property/unit identified by keys/objects ks
of the temporal entity o
, e.g.
(as (duration 1 :hours) :minutes)
=> 60
(as (local-date 2015 9) :year :month-of-year)
=> [2015 9]
-as-map
(as-map e)
(as-map e value-fn)
Converts a time entity to a map of property key -> value as defined by the passed in value-fn
. By default the actual value of the unit/field is produced.
as-map
(as-map e)
(as-map e value-fn)
Converts a time entity to a map of property key -> value as defined by the passed in value-fn
. By default the actual value of the unit/field is produced.
(as-map (duration))
=> {:nanos 0, :seconds 0}
(as-map (local-date 2015 1 1))
=> {:year 2015, :month-of-year 1, :day-of-month 1, ...}
-available-zone-ids
(available-zone-ids)
Returns a set of string identifiers for all available ZoneIds.
-before?
(before? x)
(before? x y)
(before? x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <
), otherwise false
.
available-zone-ids
(available-zone-ids)
Returns a set of string identifiers for all available ZoneIds.
+before?
(before? x)
(before? x y)
(before? x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <
), otherwise false
.
(before? (local-date 2009) (local-date 2010) (local-date 2011))
=> true
@@ -93,10 +93,10 @@
(instant 99999999))
=> true
-convert-amount
(convert-amount amount from-unit to-unit)
Converts an amount from one unit to another. Returns a map of:
+convert-amount
(convert-amount amount from-unit to-unit)
Converts an amount from one unit to another. Returns a map of:
:whole
- the whole part of the conversion in theto
unit:remainder
- the remainder in thefrom
unit
@@ -107,14 +107,14 @@
(convert-amount 10000 :seconds :hours)
=> {:remainder 2800 :whole 2}
-day-of-month
(day-of-month)
(day-of-month arg)
(day-of-month fmt arg)
Returns the DayOfMonth
for the given entity, clock, zone or day of month. Current day of month if no arguments given.
day-of-month?
(day-of-month? o)
Returns true if o
is org.threeten.extra.DayOfMonth
, otherwise false.
day-of-week
(day-of-week)
(day-of-week v)
(day-of-week fmt arg)
Returns the DayOfWeek
for the given day keyword name (e.g. :monday
), ordinal or entity. Current day if no arguments given.
day-of-year
(day-of-year)
(day-of-year arg)
(day-of-year fmt arg)
Returns the DayOfYear
for the given entity, clock, zone or day of year. Current day of year if no arguments given.
day-of-year?
(day-of-year? o)
Returns true if o
is org.threeten.extra.DayOfYear
, otherwise false.
duration
(duration)
(duration arg0)
(duration arg0 arg1)
Creates a duration - a temporal entity representing standard days, hours, minutes, millis, micros and nanos. The duration itself contains only seconds and nanos as properties.
+day-of-month
(day-of-month)
(day-of-month arg)
(day-of-month fmt arg)
Returns the DayOfMonth
for the given entity, clock, zone or day of month. Current day of month if no arguments given.
day-of-month?
(day-of-month? o)
Returns true if o
is org.threeten.extra.DayOfMonth
, otherwise false.
day-of-week
(day-of-week)
(day-of-week v)
(day-of-week fmt arg)
Returns the DayOfWeek
for the given day keyword name (e.g. :monday
), ordinal or entity. Current day if no arguments given.
day-of-year
(day-of-year)
(day-of-year arg)
(day-of-year fmt arg)
Returns the DayOfYear
for the given entity, clock, zone or day of year. Current day of year if no arguments given.
day-of-year?
(day-of-year? o)
Returns true if o
is org.threeten.extra.DayOfYear
, otherwise false.
duration
(duration)
(duration arg0)
(duration arg0 arg1)
Creates a duration - a temporal entity representing standard days, hours, minutes, millis, micros and nanos. The duration itself contains only seconds and nanos as properties.
Given one argument will:
- interpret as millis if a number @@ -127,15 +127,15 @@
- get a duration between two
Temporal
s - get a duration of a specified unit, e.g.
(duration 100 :seconds)
duration?
(duration? v)
Returns true if v
is an instance of java.time.Duration, otherwise false.
field
(field k)
(field entity k)
Returns a TemporalField
for the given key k
or extracts the field from the given temporal entity
.
duration?
(duration? v)
Returns true if v
is an instance of java.time.Duration, otherwise false.
field
(field k)
(field entity k)
Returns a TemporalField
for the given key k
or extracts the field from the given temporal entity
.
You can see predefined fields via java-time.repl/show-fields.
If you want to make your own custom TemporalFields resolvable, you need to rebind the java-time.properties/*fields*
to a custom java_time.properties.FieldGroup
.
fixed-clock
(fixed-clock)
(fixed-clock i)
(fixed-clock i z)
Creates a fixed clock either at the current instant or at the supplied instant/instant + zone.
-fixed-clock
(fixed-clock)
(fixed-clock i)
(fixed-clock i z)
Creates a fixed clock either at the current instant or at the supplied instant/instant + zone.
+format
(format o)
(format fmt o)
Formats the given time entity as a string.
Accepts something that can be converted to a DateTimeFormatter
or a formatter key, e.g. :iso-offset-time
, as a first argument. Given one argument uses the default format.
(format (zoned-date-time))
=> "2015-03-21T09:22:46.677800+01:00[Europe/London]"
@@ -143,7 +143,7 @@
(format :iso-date (zoned-date-time))
"2015-03-21+01:00"
-formatter
(formatter fmt)
(formatter fmt arg1)
Constructs a DateTimeFormatter out of a
- format string - “yyyy/MM/dd”, “HH:mm”, etc.
- formatter name - :iso-date, :iso-time, etc. @@ -153,10 +153,10 @@
resolver-style
- either:strict
,:smart
or:lenient
case
- either:insensitive
or:sensitive
(defaults to :sensitive)
friday?
(friday? i)
Returns true if the given time entity with the day-of-week
property falls on a Friday, otherwise false.
instant
(instant)
(instant arg0)
(instant arg0 arg1)
Creates an Instant
. The following arguments are supported:
friday?
(friday? i)
Returns true if the given time entity with the day-of-week
property falls on a Friday, otherwise false.
instant
(instant)
(instant arg0)
(instant arg0 arg1)
Creates an Instant
. The following arguments are supported:
- no arguments - current instant
- one argument @@ -174,11 +174,11 @@
instant->sql-timestamp
(instant->sql-timestamp instant-or-millis)
Creates a java.sql.Timestamp
from the provided instant-or-millis
- a millisecond numeric time value or something convertible to an Instant
.
instant->sql-timestamp
(instant->sql-timestamp instant-or-millis)
Creates a java.sql.Timestamp
from the provided instant-or-millis
- a millisecond numeric time value or something convertible to an Instant
.
Please consider using the JSR-310 Java Time types instead of java.sql.Timestamp
if your drivers support them.
java.sql.Timestamp
is a version of a java.util.Date
supposed to be used as a local date-time (no time zone) for the purposes of conversion from/to native JDBC driver TIMESTAMP types.
instant?
(instant? v)
Returns true if v
is an instance of java.time.Instant, otherwise false.
interval
(interval o)
(interval a b)
Constructs an interval out of a string, start and end instants or a start + duration:
+instant?
(instant? v)
Returns true if v
is an instance of java.time.Instant, otherwise false.
interval
(interval o)
(interval a b)
Constructs an interval out of a string, start and end instants or a start + duration:
(j/interval "2010-01-01T00:00:00Z/2013-01-01T00:00:00Z")
=> #<Interval 2010-01-01T00:00:00Z/2013-01-01T00:00:00Z>
@@ -189,8 +189,8 @@
=> #<Interval 1970-01-01T00:01:40Z/1970-01-01T00:16:40Z>
Requires the optional threeten-extra
dependency.
iterate
(iterate f initial v & vs)
Returns a lazy sequence of initial
, (apply f initial v vs)
, etc.
iterate
(iterate f initial v & vs)
Returns a lazy sequence of initial
, (apply f initial v vs)
, etc.
Useful when you want to produce a sequence of temporal entities, for example:
(iterate plus (days 0) 1)
=> (#<Period P0D> #<Period P1D> #<Period P2D> ...)
@@ -201,11 +201,11 @@
(iterate adjust (local-date 2010 1 1) :next-working-day)
=> (#<LocalDate 2010-01-01> #<LocalDate 2010-01-04> ...)
-java-date
(java-date)
(java-date a)
(java-date a b)
Creates a java.util.Date
out of any combination of arguments valid for instant or the Instant itself.
java-date
(java-date)
(java-date a)
(java-date a b)
Creates a java.util.Date
out of any combination of arguments valid for instant or the Instant itself.
A java.util.Date
represents an instant in time. It’s a direct analog of the java.time.Instant
type introduced in the JSR-310. Please consider using the java.time.Instant
(through instant) directly.
local-date
(local-date)
(local-date arg0)
(local-date arg0 arg1)
(local-date arg0 arg1 arg2)
Creates a LocalDate
. The following arguments are supported:
local-date
(local-date)
(local-date arg0)
(local-date arg0 arg1)
(local-date arg0 arg1 arg2)
Creates a LocalDate
. The following arguments are supported:
- no arguments - current local-date
- one argument @@ -230,7 +230,7 @@
local-date-time
(local-date-time)
(local-date-time y m d h)
(local-date-time y m d h mm)
(local-date-time y m d h mm ss)
(local-date-time y m d h mm ss n)
(local-date-time arg0)
(local-date-time arg0 arg1)
(local-date-time arg0 arg1 arg2)
Creates a LocalDateTime
. The following arguments are supported:
local-date-time
(local-date-time)
(local-date-time y m d h)
(local-date-time y m d h mm)
(local-date-time y m d h mm ss)
(local-date-time y m d h mm ss n)
(local-date-time arg0)
(local-date-time arg0 arg1)
(local-date-time arg0 arg1 arg2)
Creates a LocalDateTime
. The following arguments are supported:
- no arguments - current local date-time
- one argument
@@ -253,9 +253,9 @@
three and more arguments - year/month/day/…
local-date-time?
(local-date-time? v)
Returns true if v
is an instance of java.time.LocalDateTime, otherwise false.
local-date?
(local-date? v)
Returns true if v
is an instance of java.time.LocalDate, otherwise false.
local-time
(local-time)
(local-time h m s nn)
(local-time arg0)
(local-time arg0 arg1)
(local-time arg0 arg1 arg2)
Creates a LocalTime
. The following arguments are supported:
local-date-time?
(local-date-time? v)
Returns true if v
is an instance of java.time.LocalDateTime, otherwise false.
local-date?
(local-date? v)
Returns true if v
is an instance of java.time.LocalDate, otherwise false.
local-time
(local-time)
(local-time h m s nn)
(local-time arg0)
(local-time arg0 arg1)
(local-time arg0 arg1 arg2)
Creates a LocalTime
. The following arguments are supported:
- no arguments - current local time
- one argument @@ -275,19 +275,19 @@
- three/four arguments - hour, minute, second, nanos
local-time?
(local-time? v)
Returns true if v
is an instance of java.time.LocalTime, otherwise false.
max
(max o & os)
Latest/longest of the given time entities. Entities should be of the same type
-min
(min o & os)
Earliest/shortest of the given time entities. Entities should be of the same type
-local-time?
(local-time? v)
Returns true if v
is an instance of java.time.LocalTime, otherwise false.
max
(max o & os)
Latest/longest of the given time entities. Entities should be of the same type
+min
(min o & os)
Earliest/shortest of the given time entities. Entities should be of the same type
+minus
(minus o & os)
Subtracts all of the os
from the time entity o
(j/minus (j/local-date 2015) (j/years 1))
=> <java.time.LocalDate "2014-01-01">
-mock-clock
(mock-clock)
(mock-clock instant)
(mock-clock instant zone)
Returns a mock implementation of the java.time.Clock
. The mock supports advance-clock!
operation which allows to move the time in the clock, e.g.:
mock-clock
(mock-clock)
(mock-clock instant)
(mock-clock instant zone)
Returns a mock implementation of the java.time.Clock
. The mock supports advance-clock!
operation which allows to move the time in the clock, e.g.:
(let [clock (mock-clock 0 "UTC")]
(with-clock clock
(is (= (value clock) 0))
@@ -298,13 +298,13 @@
You can move the clock back via advancing by a negative temporal amount.
Creates a clock at epoch in the default time zone when called without arguments.
-monday?
(monday? i)
Returns true if the given time entity with the day-of-week
property falls on a Monday, otherwise false.
month
(month)
(month v)
(month fmt arg)
Returns the Month
for the given month keyword name (e.g. :january
), ordinal or entity. Current month if no arguments given.
month-day
(month-day)
(month-day arg)
(month-day a b)
Returns the MonthDay
for the given entity, string, clock, zone or month/day combination. Current month-day if no arguments given.
move-end-by
(move-end-by i & os)
Moves the end instant of the interval by the sum of given periods/durations/numbers of milliseconds.
+monday?
(monday? i)
Returns true if the given time entity with the day-of-week
property falls on a Monday, otherwise false.
month
(month)
(month v)
(month fmt arg)
Returns the Month
for the given month keyword name (e.g. :january
), ordinal or entity. Current month if no arguments given.
month-day
(month-day)
(month-day arg)
(month-day a b)
Returns the MonthDay
for the given entity, string, clock, zone or month/day combination. Current month-day if no arguments given.
move-end-by
(move-end-by i & os)
Moves the end instant of the interval by the sum of given periods/durations/numbers of milliseconds.
(move-start-by (interval 0 10000) (millis 1000) (seconds 1))
=> #<Interval ...:00Z/...:12Z>
@@ -312,7 +312,7 @@
(move-end-by (interval 0 10000) (millis -11000))
=> DateTimeException...
-move-end-to
(move-end-to i new-end)
Moves the end of the interval to the given instant (or something convertible to an instant):
+move-end-to
(move-end-to i new-end)
Moves the end of the interval to the given instant (or something convertible to an instant):
(move-end-to (interval 0 10000) (instant 15000))
=> #<Interval ...:00Z/...:15Z>
@@ -320,7 +320,7 @@
(move-end-to (interval 0 10000) (millis -1))
=> DateTimeException...
-move-start-by
(move-start-by i & os)
Moves the start instant of the interval by the sum of given periods/durations/numbers of milliseconds:
+move-start-by
(move-start-by i & os)
Moves the start instant of the interval by the sum of given periods/durations/numbers of milliseconds:
(move-start-by (interval 0 10000) (millis 1000) (seconds 1))
=> #<Interval ...:02Z/...:10Z>
@@ -328,7 +328,7 @@
(move-start-by (interval 0 10000) (millis 11000))
;=> DateTimeException...
-move-start-to
(move-start-to i new-start)
Moves the start instant of the interval to the given instant (or something convertible to an instant):
+move-start-to
(move-start-to i new-start)
Moves the start instant of the interval to the given instant (or something convertible to an instant):
(move-start-to (interval 0 10000) (instant 5000))
=> #<Interval ...:05Z/...:10Z>
@@ -336,12 +336,12 @@
(move-start-to (interval 0 10000) (millis 15000))
=> DateTimeException...
-not-after?
(not-after? x)
(not-after? x y)
(not-after? x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <=
), otherwise false
.
not-after?
(not-after? x)
(not-after? x y)
(not-after? x y & more)
Returns true
if time entities are ordered from the earliest to the latest (same semantics as <=
), otherwise false
.
(not-after? (local-date 2009) (local-date 2010) (local-date 2011))
;=> true
@@ -349,7 +349,7 @@
(instant 99999999))
;=> true
-not-before?
(not-before? x)
(not-before? x y)
(not-before? x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >=
), otherwise false
.
not-before?
(not-before? x)
(not-before? x y)
(not-before? x y & more)
Returns true
if time entities are ordered from the latest to the earliest (same semantics as >=
), otherwise false
.
(not-before? (local-date 2011) (local-date 2010) (local-date 2009))
;=> true
@@ -357,8 +357,8 @@
(interval (instant 10000) (instant 1000000)))
;=> true
-offset-clock
(offset-clock d)
(offset-clock c d)
Creates a clock offset from the current/provided clock by a given duration
.
offset-date-time
(offset-date-time)
(offset-date-time y m d h)
(offset-date-time y mo d h m)
(offset-date-time y mo d h m s)
(offset-date-time y mo d h m s n)
(offset-date-time y mo d h m s n o)
(offset-date-time arg0)
(offset-date-time arg0 arg1)
(offset-date-time arg0 arg1 arg2)
Creates an OffsetDateTime
. The following arguments are supported:
offset-clock
(offset-clock d)
(offset-clock c d)
Creates a clock offset from the current/provided clock by a given duration
.
offset-date-time
(offset-date-time)
(offset-date-time y m d h)
(offset-date-time y mo d h m)
(offset-date-time y mo d h m s)
(offset-date-time y mo d h m s n)
(offset-date-time y mo d h m s n o)
(offset-date-time arg0)
(offset-date-time arg0 arg1)
(offset-date-time arg0 arg1 arg2)
Creates an OffsetDateTime
. The following arguments are supported:
- no arguments - current date-time with the default offset
- one argument @@ -388,8 +388,8 @@
- eight arguments - time fields up to nanoseconds and a zone offset
If zone offset is not specified, default will be used. You can check the default offset by invoking (zone-offset)
.
offset-date-time?
(offset-date-time? v)
Returns true if v
is an instance of java.time.OffsetDateTime, otherwise false.
offset-time
(offset-time)
(offset-time h m s)
(offset-time h m s n)
(offset-time h m s n o)
(offset-time arg0)
(offset-time arg0 arg1)
Creates an OffsetTime
. The following arguments are supported:
offset-date-time?
(offset-date-time? v)
Returns true if v
is an instance of java.time.OffsetDateTime, otherwise false.
offset-time
(offset-time)
(offset-time h m s)
(offset-time h m s n)
(offset-time h m s n o)
(offset-time arg0)
(offset-time arg0 arg1)
Creates an OffsetTime
. The following arguments are supported:
- no arguments - current time with the default offset
- one argument @@ -414,10 +414,10 @@
- five arguments - last is the offset
If zone offset is not specified, default will be used. You can check the default offset by invoking (zone-offset)
.
offset-time?
(offset-time? v)
Returns true if v
is an instance of java.time.OffsetTime, otherwise false.
period
(period)
(period arg0)
(period arg0 arg1)
(period arg0 arg1 arg2)
Creates a period - a temporal entity consisting of years, months and days.
+offset-time?
(offset-time? v)
Returns true if v
is an instance of java.time.OffsetTime, otherwise false.
period
(period)
(period arg0)
(period arg0 arg1)
(period arg0 arg1 arg2)
Creates a period - a temporal entity consisting of years, months and days.
Given one argument will
- interpret as years if a number @@ -432,98 +432,98 @@
- get a period of a specified number of years and months
Given three arguments will create a year/month/day period.
-period?
(period? v)
Returns true if v
is an instance of java.time.Period, otherwise false.
plus
(plus o & os)
Adds all of the os
to the time entity o
. plus
is not commutative, the first argument is always the entity which will accumulate the rest of the arguments.
period?
(period? v)
Returns true if v
is an instance of java.time.Period, otherwise false.
plus
(plus o & os)
Adds all of the os
to the time entity o
. plus
is not commutative, the first argument is always the entity which will accumulate the rest of the arguments.
(j/plus (j/local-date 2015) (j/years 1))
=> <java.time.LocalDate "2016-01-01">
-quarter
(quarter)
(quarter v)
(quarter fmt arg)
Returns the Quarter
for the given quarter keyword name (e.g. :q1
), ordinal or entity. Current quarter if no arguments given.
saturday?
(saturday? i)
Returns true if the given time entity with the day-of-week
property falls on a Saturday, otherwise false.
quarter
(quarter)
(quarter v)
(quarter fmt arg)
Returns the Quarter
for the given quarter keyword name (e.g. :q1
), ordinal or entity. Current quarter if no arguments given.
saturday?
(saturday? i)
Returns true if the given time entity with the day-of-week
property falls on a Saturday, otherwise false.
set-clock!
(set-clock! clock time)
Sets the clock
to the given time
.
This mutates the mock clock.
-smallest-max-value
(smallest-max-value p)
Smallest maximum value of this property, e.g. 28th of February for months
-sql-date
(sql-date)
(sql-date arg0)
(sql-date arg0 arg1)
(sql-date arg0 arg1 arg2)
Creates a java.sql.Date
out of any combination of arguments valid for local-date or the LocalDate
itself.
smallest-max-value
(smallest-max-value p)
Smallest maximum value of this property, e.g. 28th of February for months
+sql-date
(sql-date)
(sql-date arg0)
(sql-date arg0 arg1)
(sql-date arg0 arg1 arg2)
Creates a java.sql.Date
out of any combination of arguments valid for local-date or the LocalDate
itself.
Please consider using the JSR-310 Java Time types instead of java.sql.Date
if your drivers support them.
Even though java.sql.Date
extends a java.util.Date
, it’s supposed to be used as a local date (no time component or time zone) for the purposes of conversion from/to native JDBC driver DATE types.
sql-time
(sql-time)
(sql-time arg0)
(sql-time arg0 arg1)
(sql-time arg0 arg1 arg2)
Creates a java.sql.Time
out of any combination of arguments valid for local-time (except the nanos constructor) or the LocalTime
itself.
sql-time
(sql-time)
(sql-time arg0)
(sql-time arg0 arg1)
(sql-time arg0 arg1 arg2)
Creates a java.sql.Time
out of any combination of arguments valid for local-time (except the nanos constructor) or the LocalTime
itself.
Please consider using the JSR-310 Java Time types instead of java.sql.Time
if your drivers support them.
Even though java.sql.Time
extends a java.util.Date
, it’s supposed to be used as a local time (no date component or time zone) for the purposes of conversion from/to native JDBC driver TIME types.
sql-timestamp
(sql-timestamp)
(sql-timestamp arg0)
(sql-timestamp arg0 arg1)
(sql-timestamp arg0 arg1 arg2)
(sql-timestamp arg0 arg1 arg2 arg3)
(sql-timestamp arg0 arg1 arg2 arg3 arg4)
(sql-timestamp arg0 arg1 arg2 arg3 arg4 arg5)
(sql-timestamp arg0 arg1 arg2 arg3 arg4 arg5 arg6)
Creates a java.sql.Timestamp
in the local time zone out of any combination of arguments valid for local-date-time or the LocalDateTime
itself.
sql-timestamp
(sql-timestamp)
(sql-timestamp arg0)
(sql-timestamp arg0 arg1)
(sql-timestamp arg0 arg1 arg2)
(sql-timestamp arg0 arg1 arg2 arg3)
(sql-timestamp arg0 arg1 arg2 arg3 arg4)
(sql-timestamp arg0 arg1 arg2 arg3 arg4 arg5)
(sql-timestamp arg0 arg1 arg2 arg3 arg4 arg5 arg6)
Creates a java.sql.Timestamp
in the local time zone out of any combination of arguments valid for local-date-time or the LocalDateTime
itself.
Does not support Timestamp
construction from an Instant
or a long millis value—please use instant->sql-timestamp for this purpose.
Please consider using the JSR-310 Java Time types instead of java.sql.Timestamp
if your drivers support them.
java.sql.Timestamp
is a version of a java.util.Date
supposed to be used as a local date-time (no time zone) for the purposes of conversion from/to native JDBC driver TIMESTAMP types.
sunday?
(sunday? i)
Returns true if the given time entity with the day-of-week
property falls on a Sunday, otherwise false.
system-clock
(system-clock)
(system-clock k)
Creates a system clock. In the default time zone if called without arguments, otherwise accepts a Zone Id.
-thursday?
(thursday? i)
Returns true if the given time entity with the day-of-week
property falls on a Thursday, otherwise false.
tick-clock
(tick-clock d)
(tick-clock c d)
Creates a clock wrapping system/provided clock that only ticks as per specified duration.
-sunday?
(sunday? i)
Returns true if the given time entity with the day-of-week
property falls on a Sunday, otherwise false.
system-clock
(system-clock)
(system-clock k)
Creates a system clock. In the default time zone if called without arguments, otherwise accepts a Zone Id.
+thursday?
(thursday? i)
Returns true if the given time entity with the day-of-week
property falls on a Thursday, otherwise false.
tick-clock
(tick-clock d)
(tick-clock c d)
Creates a clock wrapping system/provided clock that only ticks as per specified duration.
+time-between
(time-between o e u)
Time between temporal entities o
and e
in unit u
.
(j/time-between (j/local-date 2015) (j/local-date 2016) :days)
=> 365
(j/time-between :days (j/local-date 2015) (j/local-date 2016))
=> 365
-to-java-date
deprecated
(to-java-date o)
Converts a date entity to a java.util.Date
.
Deprecated: This function only has a single arity and works for entities directly convertible to java.time.Instant
. Please consider using java-date instead.
to-millis-from-epoch
(to-millis-from-epoch o)
Converts a date entity to a long
representing the number of milliseconds from epoch.
to-millis-from-epoch
(to-millis-from-epoch o)
Converts a date entity to a long
representing the number of milliseconds from epoch.
to-sql-date
deprecated
(to-sql-date o)
Converts a local date entity to a java.sql.Date
.
Deprecated: This function only has a single arity and works for entities directly convertible to java.time.LocalDate
. Please consider using sql-date instead.
to-sql-timestamp
deprecated
(to-sql-timestamp o)
Converts a date entity to a java.sql.Timestamp
.
to-sql-timestamp
deprecated
(to-sql-timestamp o)
Converts a date entity to a java.sql.Timestamp
.
Deprecated: This function only has a single arity and works for entities directly convertible to java.time.Instant
. Please consider using sql-timestamp instead.
truncate-to
(truncate-to o u)
Truncates this entity to the specified time unit. Only works for units that divide into the length of standard day without remainder (up to :days
).
tuesday?
(tuesday? i)
Returns true if the given time entity with the day-of-week
property falls on a Tuesday, otherwise false.
unit
(unit k)
(unit entity k)
Returns a TemporalUnit
for the given key k
or extracts the field from the given temporal entity
.
truncate-to
(truncate-to o u)
Truncates this entity to the specified time unit. Only works for units that divide into the length of standard day without remainder (up to :days
).
tuesday?
(tuesday? i)
Returns true if the given time entity with the day-of-week
property falls on a Tuesday, otherwise false.
unit
(unit k)
(unit entity k)
Returns a TemporalUnit
for the given key k
or extracts the field from the given temporal entity
.
You can see predefined units via java-time.repl/show-units.
If you want to make your own custom TemporalUnits resolvable, you need to rebind the java-time.properties/*units*
to a custom java_time.properties.UnitGroup
.
value-range
(value-range min max)
(value-range arg0)
Creates a ValueRange
given the min
and max
amounts or a map of :min-smallest
, :max-smallest
, :min-largest
and :max-largest
.
wednesday?
(wednesday? i)
Returns true if the given time entity with the day-of-week
property falls on a Wednesday, otherwise false.
weekend?
(weekend? dt)
when-joda-time-loaded
macro
(when-joda-time-loaded & body)
Execute the body
when Joda-Time classes are found on the classpath.
value-range
(value-range min max)
(value-range arg0)
Creates a ValueRange
given the min
and max
amounts or a map of :min-smallest
, :max-smallest
, :min-largest
and :max-largest
.
wednesday?
(wednesday? i)
Returns true if the given time entity with the day-of-week
property falls on a Wednesday, otherwise false.
weekend?
(weekend? dt)
when-joda-time-loaded
macro
(when-joda-time-loaded & body)
Execute the body
when Joda-Time classes are found on the classpath.
Take care - when AOT-compiling code using this macro, the Joda-Time classes must be on the classpath at compile time!
-with-clock
macro
(with-clock c & forms)
Executes the given forms
in the scope of the provided clock
.
with-clock
macro
(with-clock c & forms)
Executes the given forms
in the scope of the provided clock
.
All the temporal entities that get created without parameters will inherit their values from the clock:
(with-clock (system-clock “Europe/London”) (zone-id)) => #<java.time.ZoneRegion Europe/London>
-with-clock-fn
(with-clock-fn c f)
Executes the given function in the scope of the provided clock. All the temporal entities that get created without parameters will inherit their values from the clock.
-with-largest-min-value
(with-largest-min-value p)
Underlying temporal entity with the value set to the largest minimum available for this property
-with-max-value
(with-max-value p)
Underlying temporal entity with the value set to the maximum available for this property
-with-min-value
(with-min-value p)
Underlying temporal entity with the value set to the minimum available for this property
-with-offset
(with-offset o offset)
Sets the offset to the specified value ensuring that the local time stays the same.
+with-clock-fn
(with-clock-fn c f)
Executes the given function in the scope of the provided clock. All the temporal entities that get created without parameters will inherit their values from the clock.
+with-largest-min-value
(with-largest-min-value p)
Underlying temporal entity with the value set to the largest minimum available for this property
+with-max-value
(with-max-value p)
Underlying temporal entity with the value set to the maximum available for this property
+with-min-value
(with-min-value p)
Underlying temporal entity with the value set to the minimum available for this property
+with-offset
(with-offset o offset)
Sets the offset to the specified value ensuring that the local time stays the same.
(offset-time 10 30 0 0 +2) => #<java.time.OffsetTime 10:30+02:00> (with-offset *1 +3) => #<java.time.OffsetTime 10:30+03:00>
-with-offset-same-instant
(with-offset-same-instant o offset)
Sets the offset to the specified value ensuring that the result has the same instant, e.g.:
+with-offset-same-instant
(with-offset-same-instant o offset)
Sets the offset to the specified value ensuring that the result has the same instant, e.g.:
(offset-time 10 30 0 0 +2) => #<java.time.OffsetTime 10:30+02:00> (with-offset-same-instant *1 +3) => #<java.time.OffsetTime 11:30+03:00>
-with-smallest-max-value
(with-smallest-max-value p)
Underlying temporal entity with the value set to the smallest maximum available for this property
-with-value
(with-value p v)
Underlying temporal entity with the value of this property set to v
with-zone-same-instant
(with-zone-same-instant zdt z)
Sets the zone to the specified value ensuring that the result has the same instant, e.g.:
+with-smallest-max-value
(with-smallest-max-value p)
Underlying temporal entity with the value set to the smallest maximum available for this property
+with-value
(with-value p v)
Underlying temporal entity with the value of this property set to v
with-zone-same-instant
(with-zone-same-instant zdt z)
Sets the zone to the specified value ensuring that the result has the same instant, e.g.:
(zoned-date-time 2015) => #<java.time.ZonedDateTime 2015-01-01T00:00+00:00Europe/London> (with-zone-same-instant *1 “America/New_York”) => #<java.time.ZonedDateTime 2014-12-31T18:00-05:00America/New_York>
-year
(year)
(year arg)
(year fmt arg)
Returns the Year
for the given entity, string, clock, zone or number. Current year if no arguments given.
year-month
(year-month)
(year-month arg)
(year-month a b)
Returns the YearMonth
for the given entity, string, clock, zone or month/day combination. Current year-month if no arguments given.
year-quarter
(year-quarter)
(year-quarter arg)
(year-quarter a b)
Returns the YearQuarter
for the given entity, clock, zone or year with quarter. Current year quarter if no arguments given.
year-quarter?
(year-quarter? o)
Returns true if o
is org.threeten.extra.YearQuarter
, otherwise false.
zone-id
(zone-id)
(zone-id arg0)
(zone-id arg0 arg1)
Creates a ZoneId
from a string identifier, java.util.TimeZone
or extracts from another temporal entity.
year
(year)
(year arg)
(year fmt arg)
Returns the Year
for the given entity, string, clock, zone or number. Current year if no arguments given.
year-month
(year-month)
(year-month arg)
(year-month a b)
Returns the YearMonth
for the given entity, string, clock, zone or month/day combination. Current year-month if no arguments given.
year-quarter
(year-quarter)
(year-quarter arg)
(year-quarter a b)
Returns the YearQuarter
for the given entity, clock, zone or year with quarter. Current year quarter if no arguments given.
year-quarter?
(year-quarter? o)
Returns true if o
is org.threeten.extra.YearQuarter
, otherwise false.
zone-id
(zone-id)
(zone-id arg0)
(zone-id arg0 arg1)
Creates a ZoneId
from a string identifier, java.util.TimeZone
or extracts from another temporal entity.
Returns default system zone id if no arguments provided.
Given two arguments will use the second as the offset.
-zone-id?
(zone-id? v)
Returns true if v
is an instance of java.time.ZoneId, otherwise false.
zone-offset
(zone-offset)
(zone-offset o)
(zone-offset h m)
(zone-offset h m s)
Creates a ZoneOffset
from a string identifier (e.g. “+01”), a number of hours/hours and minutes/hours, minutes and seconds or extracts from another temporal entity.
zone-id?
(zone-id? v)
Returns true if v
is an instance of java.time.ZoneId, otherwise false.
zone-offset
(zone-offset)
(zone-offset o)
(zone-offset h m)
(zone-offset h m s)
Creates a ZoneOffset
from a string identifier (e.g. “+01”), a number of hours/hours and minutes/hours, minutes and seconds or extracts from another temporal entity.
Returns default system zone offset if no arguments provided.
-zoned-date-time
(zoned-date-time)
(zoned-date-time y m d h)
(zoned-date-time y mo d h m)
(zoned-date-time y mo d h m s)
(zoned-date-time y mo d h m s n)
(zoned-date-time y mo d h m s n o)
(zoned-date-time arg0)
(zoned-date-time arg0 arg1)
(zoned-date-time arg0 arg1 arg2)
Creates a ZonedDateTime
. The following arguments are supported:
zoned-date-time
(zoned-date-time)
(zoned-date-time y m d h)
(zoned-date-time y mo d h m)
(zoned-date-time y mo d h m s)
(zoned-date-time y mo d h m s n)
(zoned-date-time y mo d h m s n o)
(zoned-date-time arg0)
(zoned-date-time arg0 arg1)
(zoned-date-time arg0 arg1 arg2)
Creates a ZonedDateTime
. The following arguments are supported:
- no arguments - current date-time in the default zone
- one argument @@ -552,5 +552,5 @@
- eight arguments - last is the zone id
If zone id is not specified, default zone id will be used. You can check the default zone by invoking (zone-id)
.
zoned-date-time?
(zoned-date-time? v)
Returns true if v
is an instance of java.time.ZonedDateTime, otherwise false.