mapping
"createTime": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ss"
}
java 代码注解
@Field(type = FieldType.Date,
format = DateFormat.custom,
pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
private Date creatDate;
}
通过 kibana dev 查询 看到还是 utc 时间
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "student",
"_type": "student",
"_id": "dxmYhGwBAdpwDaWWx8kH",
"_score": 1,
"_source": {
"id": null,
"name": "name:",
"age": 12,
"desc": "hello world",
"area": "xian",
"creatDate": "2019-08-12T06:51:40",
"logTime": "2019-08-12T06:51:40Z"
}
}
]
}
}
最终通过kibana discover 查看结果,已经是本地时间了
建议存储的时候还是使用utc 时间,免得导致通过kibana 查询的结果对不上。