ICOCERCE会产生迄今为止的协议错误

发布于 2025-01-18 04:46:48 字数 451 浏览 3 评论 0原文

我接手了一个 Clojure 项目,遇到了如下错误:

No implementation of method: :to-date-time of protocol: #'clj-time.coerce/ICoerce found for class: java.time.LocalDateTime

我试图在这里分配一个值:

{ :start-date   (time/to-string start-date) }

我正在使用 clj-time 作为依赖项。

我感到困惑的尤其是它说的部分 没有实现方法: :to-date-time of protocol 即使我使用 time/to-string

是我需要添加该协议吗?

我们将更加感谢您的帮助。

I took over a Clojure project and I am experiencing an error as follows:

No implementation of method: :to-date-time of protocol: #'clj-time.coerce/ICoerce found for class: java.time.LocalDateTime

Where I am trying to assign a value in here:

{ :start-date   (time/to-string start-date) }

I am using clj-time as a dependency.

What I am confused about is especially the part where it says No implementation of method: :to-date-time of protocol even though I am using time/to-string

Is there a way I need to add that protocol?

Your help will be much more appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揪着可爱 2025-01-25 04:46:48

我解决了这个问题。 MYSQL 8 连接器返回 Java LocalDateTime 并且 clj-time 试图将此 LocalDateTime 转换为 Java 8 中不存在的 Joda 日期时间

我必须导入这些:

(:import [java.time LocalDateTime]
         [java.time.format DateTimeFormatter])

创建格式化程序:

(def formatter (DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss"))

然后转换为字符串:

(defn date-parser [{:keys [start-date expiry-date]}]
  {:start-date   (.toString (.format start-date formatter))
   :expiry-date  (.toString (.format expiry-date formatter))})

特别感谢 Steffan Westcott 和艾伦·汤普森

I resolved this issue. MYSQL 8 connector was returning Java LocalDateTime and clj-time was trying to convert this LocalDateTime into Joda Date time which does not exists in Java 8

I had to import those:

(:import [java.time LocalDateTime]
         [java.time.format DateTimeFormatter])

Create the formatter:

(def formatter (DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss"))

And then convert to string:

(defn date-parser [{:keys [start-date expiry-date]}]
  {:start-date   (.toString (.format start-date formatter))
   :expiry-date  (.toString (.format expiry-date formatter))})

Special thanks to Steffan Westcott and Alan Thompson

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文