Spring boot 带有Spring数据和Couchbase的Jodas LocalDateTime没有时区
我想在spring boot应用程序中持久化一个带有LocalDateTime字段、spring数据和couchbase的对象 以下是字段映射:Spring boot 带有Spring数据和Couchbase的Jodas LocalDateTime没有时区,spring-boot,spring-data,couchbase,Spring Boot,Spring Data,Couchbase,我想在spring boot应用程序中持久化一个带有LocalDateTime字段、spring数据和couchbase的对象 以下是字段映射: @Field private LocalDateTime start; @Field private LocalDateTime end; 当我保存对象时,日期将作为数字存储在couchbase中 以下是couchbase中存储的数据: "start": 1518818215508, 所以问题是,如果我存储一个LocalDateTime,例如10
@Field
private LocalDateTime start;
@Field
private LocalDateTime end;
当我保存对象时,日期将作为数字存储在couchbase中
以下是couchbase中存储的数据:
"start": 1518818215508,
所以问题是,如果我存储一个LocalDateTime,例如10.00,然后从db读取它,结果是09:00而不是10:00,因为我的本地时间+1:00
在Postgres中,我会使用mapping:columnDefinition=“TIMESTAMP with TIME ZONE”将日期保存在一列中
如何在couchbase中解决这个问题?JSON(众所周知)没有日期格式(不像关系数据库有大量不同的格式)。如果您想在JSON中存储时区数据,我可以考虑以下两个选项:
- 使用字符串而不是数字,然后使用类似
- 存储当前作为UTC值的历元时间,但也存储表示与UTC的时区偏移的单独数字字段
org.springframework.data.couchbase.useISOStringConverterForDate
设置为true来实现这一点