I have a requirement to save the current UTC date with time in an Oracle column of type TIMESTAMP WITH TIMEZONE. this is from a Spring Boot service with JPA and Hibernate
I have enabled the following in my application yml
jpa:
hibernate:
ddl-auto: none
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.Oracle12cDialect
jdbc:
time_zone: UTC
and the Entity class field looks like
@Column(name = "last_user_edit_date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
private ZonedDateTime lastUserEditDate;
While setting date I am using
obj.setLastUserEditDate(ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("UTC")));
The above is working fine with respect to the actual date value. The only problem is in the database it is saving the UTC time but mentions MST (my local timezone) as the timezone. For eg a value saved is
12-SEP-19 09.50.53.820000000 PM AMERICA/DENVER
Here the 9.50 PM is actually the UTC time but the timezone comes as AMERICA/DENVER. What i want is
12-SEP-19 09.50.53.820000000 PM UTC
How can i achieve this Spring JPA and with Java 8 classes?
Thanks