title: Setting date format output in spring rest with gson
body: <p>I have a legacy application which uses Spring-Rest and Google-GSON (declared in pom.xml) for serializing/deserializing Objects. In one of these objects there's a java.util.Date property, I want to set the date format but I cannot find how to do it.</p>
  
  <p>I can't even switch to Jackson because a colleague of mine uses it explicitly in a part of his code.</p>
  
  <p>How can I set the date format in this scenario?</p>
  
  <p>This application doesn't use Spring Boot. Everything I found for this problem is about Spring-boot + Jackson.</p>
  
  <p>EDIT: I add some details. I have this Class:</p>
  
  <pre><code>@Entity
  @Table(name="WEB_ELENCO_SCHEMI")
  @IdClass(PK.class)
  public class WebElencoSchemi implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name="COD_ARCHIVIO_ARCAM")
      private BigDecimal codArchivioArcam;
  
      @Temporal(TemporalType.DATE)
      @Column(name="DATA_AGGIORNAM")
      private Date dataAggiornam;
  
      ...
  }
  </code></pre>
  
  <p>And this repository:</p>
  
  <pre><code>public interface WebElencoSchemiRepository extends CrudRepository&lt;WebElencoSchemi, BigDecimal&gt; {
      public List&lt;WebElencoSchemi&gt; findByCodArchivioArcam(BigDecimal codArchivioArcam);
  </code></pre>
  
  <p>I want to set the format of dataAggiornam JSON output. I'm using GSON as serializator/deserializator for Spring Rest, as defined in pom.xml.</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.2.4&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I tried adding a spring.gson.date-format property in my properties file with no success.</p>
  
  <p>I'm NOT using Spring boot and I cannot switch to Jackson (in which the problem is solved with a simple annotation on the class property).</p>