在下面的记录中,我们有一个ZonedDateTime的defmethod,它在print-table中被忽略,但在使用print-str col而非str col的print-table2中被使用
;; 隐藏时区位置
(defmethod print-method java.time.ZonedDateTime
[v ^java.io.Writer w]
(.write w "#inst \"")
(.write w (.format v java.time.format.DateTimeFormatter/ISO_OFFSET_DATE_TIME))
(.write w "\""))
=> #object[clojure.lang.MultiFn 0x7a030531 "clojure.lang.MultiFn@7a030531"]
(clojure.pprint/print-table [{:a (java.time.ZonedDateTime/now)}])
| :a |
|-------------------------------------------------|
| 2021-04-17T20:55:56.794+12:00[Pacific/Auckland] |
=> nil
(print-table2 [{:a (java.time.ZonedDateTime/now)}])
| :a |
|-------------------------------------------------|
| #inst "2021-04-17T20:56:48.715+12:00" |