Get yesterday's date in Clojure -


i need yesterday's date (not user-based, relative server) in format yyyy-mm-dd.

what best way achieve in clojure?

with java 8 time api:

(import (java.time localdate)         (java.time.format datetimeformatter))  (def formatter (datetimeformatter/ofpattern "yyyy-mm-dd"))  (def yesterday (.minusdays (localdate/now) 1))  (.format formatter yesterday) ;; => "2017-04-05" 

or java 8 time api clojure wrapper: clojure.java-time

(require '[java-time :as t])  (def yesterday (t/minus (t/local-date)                         (t/days 1)))  (t/format "yyyy-mm-dd" yesterday) ;; => "2017-04-05" 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -