title: LocalDateTime , ZonedDateTime and Timestamp
body: <p>I have a SpringBoot app. using Spring Initializer, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file.</p>
  
  <p>I have a domain object with 2 properties (initDate, endDate). I want to create 2 converters to deal with mySQL DB</p>
  
  <pre><code>@Convert(converter = LocalDateTimeAttributeConverter.class) 
  private LocalDateTime initDate;
  
  @Convert(converter = ZonedDateTimeAttributeConverter.class) 
  private ZonedDateTime endDate;
  </code></pre>
  
  <p>the converter 1 (is OK)</p>
  
  <pre><code>@Converter
  public class LocalDateTimeAttributeConverter implements AttributeConverter&lt;LocalDateTime, Timestamp&gt; {
  
      @Override
      public Timestamp convertToDatabaseColumn(LocalDateTime localDateTime) {
          return (localDateTime == null ? null : Timestamp.valueOf(localDateTime));
      }
  
      @Override
      public LocalDateTime convertToEntityAttribute(Timestamp sqlTimestamp) {
          return (sqlTimestamp == null ? null : sqlTimestamp.toLocalDateTime());
      }
  }
  </code></pre>
  
  <p>This is the one that I want to create</p>
  
  <pre><code>@Converter
  public class ZonedDateTimeAttributeConverter implements AttributeConverter&lt;ZonedDateTime, Timestamp&gt; {
  
      @Override
      public Timestamp convertToDatabaseColumn(ZonedDateTime zoneDateTime) {
          return (zoneDateTime == null ? null : Timestamp.valueOf(zoneDateTime));
      }
  
  
      @Override
      public ZonedDateTime convertToEntityAttribute(Timestamp sqlTimestamp) {
          return (sqlTimestamp == null ? null : sqlTimestamp.toZonedDateTime());
      }
  }
  </code></pre>
  
  <p>But I can't because I have 2 errors:</p>
  
  <pre><code>The method valueOf(String) in the type Timestamp is not applicable for the arguments (ZonedDateTime)
  </code></pre>
  
  <p>and the TimeStamp does not have the method <code>toZonedDateTime()</code></p>
  
  <p>and if I don't add any converter for the ZonedDate, JPA creates a table with the type <code>varbinary(255)</code></p>