Utilities for parsing and unparsing DateTimes as Strings.
Parsing and printing are controlled by formatters. You can either use one of the built in ISO 8601 and a single RFC 822 formatters or define your own, e.g.:
(def built-in-formatter (formatters :basic-date-time)) (def custom-formatter (formatter "yyyyMMdd"))
To see a list of available built-in formatters and an example of a date-time printed in their format:
(show-formatters)
Once you have a formatter, parsing and printing are straightforward:
=> (parse custom-formatter "20100311") #<DateTime 2010-03-11T00:00:00.000Z>
=> (unparse custom-formatter (date-time 2010 10 3)) "20101003"
By default the parse function always returns a DateTime instance with a UTC time zone, and the unparse function always represents a given DateTime instance in UTC. A formatter can be modified to different timezones, locales, etc with the functions with-zone, with-locale, with-chronology, with-default-year and with-pivot-year.
Utilities for parsing and unparsing DateTimes as Strings. Parsing and printing are controlled by formatters. You can either use one of the built in ISO 8601 and a single RFC 822 formatters or define your own, e.g.: (def built-in-formatter (formatters :basic-date-time)) (def custom-formatter (formatter "yyyyMMdd")) To see a list of available built-in formatters and an example of a date-time printed in their format: (show-formatters) Once you have a formatter, parsing and printing are straightforward: => (parse custom-formatter "20100311") #<DateTime 2010-03-11T00:00:00.000Z> => (unparse custom-formatter (date-time 2010 10 3)) "20101003" By default the parse function always returns a DateTime instance with a UTC time zone, and the unparse function always represents a given DateTime instance in UTC. A formatter can be modified to different timezones, locales, etc with the functions with-zone, with-locale, with-chronology, with-default-year and with-pivot-year.
(formatter fmts)
(formatter fmts dtz)
(formatter dtz fmts & more)
Returns a custom formatter for the given date-time pattern or keyword.
Returns a custom formatter for the given date-time pattern or keyword.
(formatter-local fmt)
Returns a custom formatter with no time zone info.
Returns a custom formatter with no time zone info.
Map of ISO 8601 and a single RFC 822 formatters that can be used for parsing and, in most cases, printing.
Map of ISO 8601 and a single RFC 822 formatters that can be used for parsing and, in most cases, printing.
(instant->map instant)
Returns a map representation of the given instant. It will contain the following keys: :years, :months, :days, :hours, :minutes and :seconds.
Returns a map representation of the given instant. It will contain the following keys: :years, :months, :days, :hours, :minutes and :seconds.
(parse s)
(parse fmt s)
Returns a DateTime instance in the UTC time zone obtained by parsing the given string according to the given formatter.
Returns a DateTime instance in the UTC time zone obtained by parsing the given string according to the given formatter.
(parse-local s)
(parse-local fmt s)
Returns a LocalDateTime instance obtained by parsing the given string according to the given formatter.
Returns a LocalDateTime instance obtained by parsing the given string according to the given formatter.
(parse-local-date s)
(parse-local-date fmt s)
Returns a LocalDate instance obtained by parsing the given string according to the given formatter.
Returns a LocalDate instance obtained by parsing the given string according to the given formatter.
(parse-local-time s)
(parse-local-time fmt s)
Returns a LocalTime instance obtained by parsing the given string according to the given formatter.
Returns a LocalTime instance obtained by parsing the given string according to the given formatter.
(show-formatters)
(show-formatters dt)
Shows how a given DateTime, or by default the current time, would be formatted with each of the available printing formatters.
Shows how a given DateTime, or by default the current time, would be formatted with each of the available printing formatters.
(unparse fmt dt)
Returns a string representing the given DateTime instance in UTC and in the form determined by the given formatter.
Returns a string representing the given DateTime instance in UTC and in the form determined by the given formatter.
(unparse-local fmt dt)
Returns a string representing the given LocalDateTime instance in the form determined by the given formatter.
Returns a string representing the given LocalDateTime instance in the form determined by the given formatter.
(unparse-local-date fmt ld)
Returns a string representing the given LocalDate instance in the form determined by the given formatter.
Returns a string representing the given LocalDate instance in the form determined by the given formatter.
(unparse-local-time fmt lt)
Returns a string representing the given LocalTime instance in the form determined by the given formatter.
Returns a string representing the given LocalTime instance in the form determined by the given formatter.
(with-chronology f c)
Return a copy of a formatter that uses the given Chronology.
Return a copy of a formatter that uses the given Chronology.
(with-default-year f default-year)
Return a copy of a formatter that uses the given default year.
Return a copy of a formatter that uses the given default year.
(with-locale f l)
Return a copy of a formatter that uses the given Locale.
Return a copy of a formatter that uses the given Locale.
(with-pivot-year f pivot-year)
Return a copy of a formatter that uses the given pivot year.
Return a copy of a formatter that uses the given pivot year.
(with-zone f dtz)
Return a copy of a formatter that uses the given DateTimeZone.
Return a copy of a formatter that uses the given DateTimeZone.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close