<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged date</title>
<link>https://ask.clojure.org/index.php/tag/date</link>
<description></description>
<item>
<title>printing and reading date types</title>
<link>https://ask.clojure.org/index.php/11898/printing-and-reading-date-types</link>
<description>&lt;p&gt;To my understanding, Clojure's &lt;code&gt;pr&lt;/code&gt; function prints objects so that when read back will be &lt;code&gt;=&lt;/code&gt; to the original object. My main source for this come s from this talk &lt;a rel=&quot;nofollow&quot; href=&quot;https://youtu.be/pbodL96HM28?t=216&quot;&gt;https://youtu.be/pbodL96HM28?t=216&lt;/a&gt; from Clojure core developer Stuart Sierra ( I cannot find any docs to say what guarantees pr offers).&lt;/p&gt;
&lt;p&gt;If this is correct, then &lt;code&gt;pr&lt;/code&gt; is not working for java.sql.Timestamp and java.util.Calendar. For example, this returns false.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [d (java.sql.Timestamp. 1)]
(= d
(read-string
  (pr-str d))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Further, Clojure's documentation says , &lt;em&gt;print-dup&lt;/em&gt;, when true, means that &lt;code&gt;objects will be printed in a way that preserves their type when read in later&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is not the case for java.sql.Timestamp and java.util.Calendar&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(binding [*print-dup* true]&lt;br&gt;
  (prn (java.sql.Timestamp. 1)))&lt;br&gt;
=&amp;gt;  #inst &quot;1970-01-01T00:00:00.001000000-00:00&quot;&lt;/p&gt;
&lt;p&gt;As well as being interesting to get some answers to the above, understanding these issues might give some basis for Clojure's support of java.time date types as tracked by &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2224&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2224&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;I understand the above behaviour can be changed by users, but I am asking about the default implementations.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11898/printing-and-reading-date-types</guid>
<pubDate>Fri, 20 May 2022 05:31:02 +0000</pubDate>
</item>
</channel>
</rss>