Last active
August 29, 2015 14:07
-
-
Save hlship/34d93be1f292561a7ac8 to your computer and use it in GitHub Desktop.
Force all Dates and Timestamps to use UTC
This file contains hidden or 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
(ns setup | |
(:import | |
[java.util Date Calendar TimeZone] | |
[java.sql PreparedStatement]) | |
(:require | |
[clj-time.coerce :as coerce] | |
[clojure.java.jdbc :as jdbc])) | |
(extend-type Date | |
jdbc/ISQLParameter | |
(set-parameter [val ^PreparedStatement stmt ix] | |
(let [cal (Calendar/getInstance (TimeZone/getTimeZone "UTC"))] | |
(.setTimestamp stmt ix (coerce/to-timestamp val) cal)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment