Created
January 31, 2018 22:54
-
-
Save jjhop/5d80a8a8314c4be5ffc96dc69c1fab14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import '(java.util Date Calendar) | |
'(java.text SimpleDateFormat)) | |
(defn yesterday-start-as-string [] | |
"Returns the beginning of yesterday as a formatted string. | |
For example 2015-12-21 00:00:00 - hours, minutes and seconds are | |
always zeros." | |
(let [dt (.getTime (doto (Calendar/getInstance) | |
(.setTime (Date.)) | |
(.set Calendar/HOUR_OF_DAY 0) | |
(.set Calendar/MINUTE 0) | |
(.set Calendar/SECOND 0) | |
(.set Calendar/MILLISECOND 0) | |
(.set Calendar/DAY_OF_MONTH -1))) | |
ft (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss")] | |
(.format ft dt))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment