Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.util.Date in Spring Data Rest
    text
    copied!<p>I'm using a java.util.Date in spring(3.1) data REST. How can I get the date to print in a human readable form? (e.g. MM/DD/YYYY)?</p> <pre><code>@Entity public class MyEntity{ ... @Column(name="A_DATE_COLUMN") @DateTimeFormat(iso=ISO.DATE) private Date aDate; ..getters and setters } </code></pre> <p>However when i print my entity(after overriding toString), I'm always getting the date as a long. It seems like @DateTimeFormat does not change the behaviour. I also tried different iso formats and that didnt help either.</p> <pre><code>"aDate" : 1320130800000 </code></pre> <p>Here is my POM file entry for the spring data rest </p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.springframework.data&lt;/groupId&gt; &lt;artifactId&gt;spring-data-rest-webmvc&lt;/artifactId&gt; &lt;version&gt;1.0.0.RELEASE&lt;/version&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;&lt;/groupId&gt; &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;exclusion&gt; &lt;artifactId&gt;commons-logging&lt;/artifactId&gt; &lt;groupId&gt;commons-logging&lt;/groupId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;joda-time&lt;/groupId&gt; &lt;artifactId&gt;joda-time&lt;/artifactId&gt; &lt;version&gt;2.1&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Any help is much appeciated. PS. Here is the toString Implementation</p> <pre><code>@Override public String toString() { return getClass().getName() + "{"+ "\n\taDate: " + aDate + "\n}"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload