I'm not succeeding at setting a CET timezone for my JPA application, which is using the AuditingEntityListener to augment creation/lastmodified dates.
Things I tried already:
In my application.properties (both combinations):
spring.jpa.properties.hibernate.jdbc.time_zone=UTC+1
spring.jpa.properties.hibernate.jdbc.time_zone=CET
Added timezone to my JDBC connection (both combinations)
spring.datasource.url=jdbc:mysql://host:3306/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC+1
spring.datasource.url=jdbc:mysql://host:3306/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CET
Added a postconstruct (application level)
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC+1"));
}
And also tried setting the timezone at database level using:
SET time_zone='+01:00';
No succeed whatsoever, Am I missing something?
Using the @createdDate as follows:
EDIT
@Data
@Builder
@Entity
@EntityListeners(AuditingEntityListener.class)
@NoArgsConstructor
@AllArgsConstructor
public class OrderHistoryRecord {
@Id
@GeneratedValue
@JsonIgnore
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Order.class)
@JoinColumn(name = "order_id", updatable = false)
@JsonIgnore
private Order order;
@CreatedDate
private Date date;
@Enumerated(EnumType.STRING)
private PaymentStatus paymentStatus;
@Enumerated(EnumType.STRING)
private ShipmentStatus shipmentStatus;
@Enumerated(EnumType.STRING)
private OrderHistoryRecordType type;
}