From 77bd7995135f7696df3710e52f28be9770536134 Mon Sep 17 00:00:00 2001 From: Henry Widd Date: Wed, 22 Jul 2020 14:28:36 +0100 Subject: [PATCH] add support for using java.time instead of joda time --- src/amazonica/core.clj | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/amazonica/core.clj b/src/amazonica/core.clj index 673c0c5..9a9d3da 100644 --- a/src/amazonica/core.clj +++ b/src/amazonica/core.clj @@ -35,7 +35,8 @@ java.nio.ByteBuffer java.text.ParsePosition java.text.SimpleDateFormat - java.util.Date)) + java.util.Date + java.time.Instant)) (defonce ^:private credential (atom {})) @@ -321,6 +322,7 @@ [date] (cond (instance? java.util.Date date) date + (instance? Instant date) (java.util.Date/from date) (instance? AbstractInstant date) (.toDate ^AbstractInstant date) (integer? date) (java.util.Date. (int date)) true (.. (SimpleDateFormat. @date-format) @@ -744,6 +746,11 @@ (get-fields obj) obj))) +(defn marshall-date-to-java-time! [] + (extend-protocol IMarshall + java.util.Date + (marshall [obj] (.toInstant obj)))) + (defn- use-aws-request-bean? [^Method method args] (let [types (.getParameterTypes method)]