File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1+ ## 0.3.0
2+
3+ ### Fixed
4+
5+ * * Breaking* : ` to-sql-date ` converts anything convertible to ` LocalDate ` into a ` java.sql.Date ` .
6+ Previously ` to-sql-date ` worked the same as ` to-java-date ` .
7+
18## 0.2.2
29
310### Fixed
Original file line number Diff line number Diff line change 11(ns java-time.convert
22 (:require [java-time.core :as jt.c]
33 [java-time.util :as jt.u]
4+ [java-time.local :as jt.l]
45 [java-time.properties :as jt.p]
56 [java-time.temporal :as jt.t])
67 (:import [java.time.temporal TemporalUnit ChronoUnit]
8889 (Date/from (jt.t/instant o))))
8990
9091(defn ^java.sql.Date to-sql-date
91- " Converts a date entity to a `java.sql.Date`."
92- [o]
93- (java.sql.Date/from (jt.t/instant o)))
92+ " Converts a local date entity to a `java.sql.Date`.
93+
94+ This function only has a single arity and works for entities directly
95+ convertible to `java.time.LocalDate`. Please consider using `sql-date`
96+ instead."
97+ [o] (java.sql.Date/valueOf (jt.l/local-date o)))
9498
9599(defn ^java.sql.Timestamp to-sql-timestamp
96100 " Converts a date entity to a `java.sql.Timestamp`."
Original file line number Diff line number Diff line change 605605 (testing " converts through instant"
606606 (is (= (j/instant 1000 ) (j/instant (java.util.Date. 1000 ))))
607607 (is (= (java.util.Date. 1000 ) (j/to-java-date 1000 )))
608- (is (= (java.sql.Date. 1000 ) (j/to-sql-date 1000 )))
608+ (is (= (java.sql.Date/valueOf ( j/local-date 1000 ) ) (j/to-sql-date 1000 )))
609609 (is (= (java.sql.Timestamp. 1000 ) (j/to-sql-timestamp 1000 )))
610610 (is (= 1000
611611 (j/to-millis-from-epoch 1000 )
612612 (j/to-millis-from-epoch (java.util.Date. 1000 ))
613613 (j/to-millis-from-epoch (j/offset-date-time (j/instant 1000 ) +0 )))))
614614
615+ (testing " converts to java.util/sql Dates"
616+ (is (= (java.util.Date. 1000 ) (j/to-java-date (j/instant 1000 ))))
617+ (is (= (java.sql.Date/valueOf (j/local-date 2016 )) (j/to-sql-date (j/local-date 2016 )))))
618+
615619 (testing " from java.util Date types"
616620 (is (= (j/zone-id " UTC" ) (j/zone-id (java.util.TimeZone/getTimeZone " UTC" ))))))
617621
You can’t perform that action at this time.
0 commit comments