什么是Clojure时间和日期库? [英] What are the Clojure time and date libraries?

查看:90
本文介绍了什么是Clojure时间和日期库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 http://clojure.org/libraries 中找不到处理时间和日期的图书馆。有没有什么,或者这是我必须弄清楚如何直接使用Java做的?

I couldn't find libraries dealing with Time and Date in http://clojure.org/libraries. Are there any, or is this something I have to figure out how to do directly with Java?

推荐答案

clj-time 是Java Joda-Time的包装器。

clj-time is a wrapper around Java Joda-Time.

如果你使用Leiningen或Maven,您可以通过 Clojars 将其添加到您的项目中。

If you use Leiningen or Maven, you can add it to your project via Clojars.

GitHub页面上有很多示例,介绍如何进行日期算术和解析/格式化。例如:

There are lots of samples on the GitHub page which show how to do date arithmetic and parsing/formatting. For example:

(in-minutes (duration (date-time 1986 10 2) (date-time 1986 10 14)))
;; gives 17280

(def custom-formatter (formatter \"yyyyMMdd\"))

(parse custom-formatter "20100311")
;; gives #<DateTime 2010-03-11T00:00:00.000Z>

(unparse custom-formatter (date-time 2010 10 3))
;; gives "20101003"

这篇关于什么是Clojure时间和日期库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆