Reputation: 73
After upgrading from spring boot 1.2.6.RELEASE -> 1.3.1.RELEASE there seems to be a problem when using iso 8101 dateformat with timezone offset. In my application.yml the jackson date-format is set to format with timezone offset
spring:
jackson:
date-format: yyyy-MM-dd'T'HH:mm:ss.SSSXXX
With boot 1.2.6 this results in datetime formats with the correct iso 8601 timezone format like 2014-01-01T23:01:01.010+01:00
But with boot 1.3.1 the format is kept in Zulu time zone 2014-01-01T22:01:01.010Z
Upvotes: 0
Views: 2745
Reputation: 73
With thanks to @dimuha I figured it out. You have to add the time-zone property too to have the same behavior as before the upgrade
spring:
jackson:
date-format: yyyy-MM-dd'T'HH:mm:ss.SSSXXX
time-zone: Europe/Berlin
This will output 2014-01-01T23:01:01.010+01:00 iso 8601 dates.
Upvotes: 2
Reputation: 1261
By default Jackson uses GMT time zone. You can change it by adding to your configuration file:
spring:
jackson:
time-zone: Europe/Berlin
or change it for certain property by using
public class DateStuff {
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd,HH:00", timezone="CET")
public Date creationTime;
}
Upvotes: 2