title: Custom DateTime format in Spring Data Projection
body: <p>I have a spring data projection that inlines some relational fields. When the projection is applied, datetime fields are no longer outputted as iso8601 (like they are without the projection), but are instead outputted in another format.</p>
  
  <p>How do I make my projection format a datetime as ISO8601? Here's my projection currently:</p>
  
  <pre><code>package io.cocept.model.projection;
  
  import io.cocept.model.Meeting;
  import io.cocept.model.User;
  import org.springframework.data.rest.core.config.Projection;
  import org.springframework.format.annotation.DateTimeFormat;
  
  @Projection(name = "inlineUsers", types = { Meeting.class })
  public interface MeetingInlineUsersProjection {
  
      String getAddress();
      String getDateTime();    
      String getMessage();
  
      User getOwner();
      User getInvitee();
  
  }
  </code></pre>
  
  <p>and my Meeting class:</p>
  
  <pre><code>package io.cocept.model;
  
  import javax.persistence.*;
  import javax.validation.constraints.NotNull;
  import java.util.Date;
  
  @Entity
  public class Meeting extends BaseEntity {
  
      private User owner;
      private User invitee;
      private String address;
      private Date dateTime;
      private String message;
  
      public Meeting() {
  
      }
  
  
      @ManyToOne
      @NotNull
      @JoinColumn(name = "owner_id")
      public User getOwner() {
          return owner;
      }
      public void setOwner(User owner) {
          this.owner = owner;
      }
  
      @ManyToOne
      @NotNull
      @JoinColumn(name = "invitee_id")
      public User getInvitee(){
          return invitee;
      }
      public void setInvitee(User invitee){
          this.invitee = invitee;
      }
  
      @NotNull
      public String getAddress() {
          return address;
      }
      public void setAddress(String address) {
          this.address = address;
      }
  
      @NotNull
      public Date getDateTime() {
          return dateTime;
      }
      public void setDateTime(Date dateTime) {
          this.dateTime = dateTime;
      }
  
      public String getMessage(){ return message; }
      public void setMessage(String message){ this.message = message; }
  
  }
  </code></pre>
  
  <p>I've tried adding the decorator <code>@DateTimeFormat(pattern = "YYYY")</code> to the getDateTime() property but it doesn't change the outputted date format.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks
  Max</p>