How do I save timestamps in mysql DB using a hibernate entity in specific format.
Hibernate Entity Class:
@CreationTimestamp
@Column(name="created_on", nullable = false, updatable = false)
private LocalDateTime createdOn;
@UpdateTimestamp
@Column(name="updated_on", nullable = false)
private LocalDateTime updatedOn; // = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
I have also used DateTimeFormatter and SimpleDateFormat but they all gave the same error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unsupported property type [java.time.format.DateTimeFormatter] for @CreationTimestamp or @UpdateTimestamp generator annotation
application.properties:
spring.jpa.hibernate.ddl-auto=update