clj-time.coerce

Utilites to coerce Joda DateTime instances to and from various other types.
For example, to convert a Joda DateTime to and from a Java long:

  => (to-long (date-time 1998 4 25))
  893462400000

  => (from-long 893462400000)
  #<DateTime 1998-04-25T00:00:00.000Z>

from-date

(from-date date)
Returns a DateTime instance in the UTC time zone corresponding to the given
Java Date object.

from-long

(from-long millis)
Returns a DateTime instance in the UTC time zone corresponding to the given
number of milliseconds after the Unix epoch.

from-sql-date

(from-sql-date sql-date)
Returns a DateTime instance in the UTC time zone corresponding to the given
java.sql.Date object.

from-sql-time

(from-sql-time sql-time)
Returns a DateTime instance in the UTC time zone corresponding to the given
java.sql.Timestamp object.

from-string

(from-string s)
return DateTime instance from string using
formatters in clj-time.format, returning first
which parses

ICoerce

protocol

members

to-date-time

(to-date-time obj)
Convert `obj` to a Joda DateTime instance.

in-time-zone

(in-time-zone obj tz)
Convert `obj` into `tz`, return org.joda.time.LocalDate instance.

to-date

(to-date obj)
Convert `obj` to a Java Date instance.

to-epoch

(to-epoch obj)
Convert `obj` to Unix epoch.

to-local-date

(to-local-date obj)
Convert `obj` to a org.joda.time.LocalDate instance

to-local-date-time

(to-local-date-time obj)
Convert `obj` to a org.joda.time.LocalDateTime instance

to-long

(to-long obj)
Convert `obj` to the number of milliseconds after the Unix epoch.

to-sql-date

(to-sql-date obj)
Convert `obj` to a java.sql.Date instance.

to-sql-time

(to-sql-time obj)
Convert `obj` to a java.sql.Timestamp instance.

to-string

(to-string obj)
Returns a string representation of obj in UTC time-zone
using (ISODateTimeFormat/dateTime) date-time representation.

to-timestamp

(to-timestamp obj)
Convert `obj` to a Java SQL Timestamp instance.