package com.ticketmanor.model.jpa;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/** JPA Converter for LocalDate, remove when JPA catches up with Java 8
 * @author Steven Gertiser, https://weblogs.java.net/blog/montanajava/archive/2014/06/17/using-java-8-datetime-classes-jpa
 */
@Converter(autoApply = true)
public class LocalDatePersistenceConverter
	implements AttributeConverter<LocalDate, Timestamp> {
	
    @Override
    public java.sql.Timestamp convertToDatabaseColumn(LocalDate entityValue) {
        return Timestamp.valueOf(LocalDateTime.of(entityValue, LocalTime.of(0,0)));
    }

    @Override
    public LocalDate convertToEntityAttribute(java.sql.Timestamp databaseValue) {
        return databaseValue.toLocalDateTime().toLocalDate();
    }
}

@@ -310,16 +310,32 @@
 @author 
+Based on one by 
 Steven G
@@ -355,29 +355,34 @@
 s://
-weblogs.java.net
+community.oracle.com
 /blog
+s
 /mon
@@ -394,16 +394,8 @@
 ava/
-archive/
 2014
@@ -403,9 +403,9 @@
 06/1
-7
+6
 /usi
@@ -557,27 +557,28 @@
 te, 
-Timestamp
+java.sql.Date
 %3E %7B%0A%09%0A
-    
+%09
 @Ove
@@ -603,25 +603,20 @@
 ava.sql.
-Timestamp
+Date
  convert
@@ -676,74 +676,41 @@
 urn 
-Timestamp.valueOf(LocalDateTime.of(entityValue, LocalTime.of(0,0))
+java.sql.Date.valueOf(entityValue
 );%0A 
@@ -784,25 +784,20 @@
 ava.sql.
-Timestamp
+Date
  databas
@@ -806,31 +806,26 @@
 alue) %7B%0A
-        
+%09%09
 return 
+(
 database
@@ -833,26 +833,33 @@
 alue
-.toLocalDateTime()
+ != null) ? databaseValue
 .toL
@@ -868,16 +868,23 @@
 alDate()
+ : null
 ;%0A    %7D%0A

handle nulls