title: Postgres UTC to Java ZonedDateTime
body: <p>Follow-up question to my original <a href="https://stackoverflow.com/questions/36417317/localdatetime-to-zoneddatetime">issue</a>.</p>
  
  <p>Because I know that any date time used is against a known timezone, rather than where the user may be submitting their request from, I take a LocalDateTime, convert to UTC and persist.  Then, when the appointment is retrieved I convert the saved time to the meeting location timezone (stored in db).  However, it would seem that the values I save are actually being saved in my local timezone.</p>
  
  <p>I receive a date time value in the Rest Controller such as:</p>
  
  <pre><code>startLocalDateTime: 2016-04-11T10:00
  endLocalDateTime: 2016-04-11T10:30
  </code></pre>
  
  <p>Appointment has two ZoneDateTime fields:</p>
  
  <pre><code>@Column(name = "startDateTime", columnDefinition= "TIMESTAMP WITH TIME ZONE")
  private ZonedDateTime startDateTime;
  @Column(name = "endDateTime", columnDefinition= "TIMESTAMP WITH TIME ZONE")
  private ZonedDateTime endDateTime;
  </code></pre>
  
  <p>Then I change the values to UTC and store on my entity to store to Postgres:</p>
  
  <pre><code>appointment.setStartDateTime(startLocalDateTime.atZone(ZoneId.of( "UTC" )))
  appointment.setEndDateTime(endLocalDateTime.atZone(ZoneId.of( "UTC" )))
  </code></pre>
  
  <p>and I store that in Postgres <code>(columnDefinition= "TIMESTAMP WITH TIME ZONE")</code>  When I look at the record in pgadminIII I see:</p>
  
  <pre><code>startDateTime "2016-04-11 04:00:00-06"
  endDateTime  "2016-04-11 04:30:00-06"
  </code></pre>
  
  <p>So these appear to be stored properly in UTC format (please correct me if I am doing anything wrong so far).  I then retrieve them from the database and they are returned as:</p>
  
  <pre><code>Appointment
  startdatetime: 2016-04-11T04:00-06:00[America/Denver]
  enddatetime: 2016-04-11T04:30-06:00[America/Denver]
  </code></pre>
  
  <p>Those values are sent back as JSON:</p>
  
  <pre><code>{  
   "appointmentId":50,
   "startDateTime":"2016-04-11T04:00",
   "endDateTime":"2016-04-11T04:30"
  }
  </code></pre>
  
  <p>So even though I am saving them as UTC, when I retrieve them they are in MST (my local) timezone, rather than UTC, and I am unable to convert them back to the actual time.  </p>
  
  <p>Still struggling with the persistence.  I have tried using the java.sql.timestamp, java.sql.Date, java.util.Date, and java.time.ZonedDateTime on my entity.  My Postgres is still a "timestamp with time zone".  But because I am using Spring-Data-JPA and need to query with the same type.  If I use Date - should that be sql.Date or util.Date? </p>