我有一个dto类有字段
@Future(message = "Invalid Past Time")
@DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "hh:mm a")
@JsonProperty(value = "time")
private LocalTime reservationTime;### when i run on my localhost works fine but when i deploy to heroku the time after deserialization become local time-2 hours 我试过:
@Future(message = "Invalid Past Time")
@DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "hh:mm a", timezone = "Africa/Cairo")
@JsonProperty(value = "time")
private LocalTime reservationTime;但不是工作我也试过
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true);
return mapper;
}我的问题在哪里?
发布于 2022-02-27 18:29:10
请检查此示例,并添加这是数据源application.properties
spring.datasource.url=jdbc:mysql://localhost:8080/database_name?serverTimezone=UTChttps://stackoverflow.com/questions/71268669
复制相似问题