zoukankan      html  css  js  c++  java
  • es~日期类型需要注意的

    es的Date类型支持的格式是有限的,默认是一个时间戳,可读性不是很好,需要解析之后才能使用,而它默认支持的格式只有如下几种,如果你在java里格式化的字符串不属于以下几种,将会出错。

    UTC时间

      //kibana里索引字段
      @Field(type = FieldType.Date, format = DateFormat.custom, pattern ="yyyy-MM-ddTHH:mm:ss.SSSZ")// 指定存储格式
      @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")// 数据格式转换,并加上8小时进行存储
      private String timestamp;
    
     esPathHandlerEntity.setTimestamp(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()));
     esPathHandlerRepository.save(esPathHandlerEntity);
    

    本地时间,kibana里索引需要这样做

      //kibana里索引字段
      @Field(type = FieldType.Date, format = DateFormat.custom, pattern ="yyyy-MM-ddTHH:mm:ss+0800")// 指定存储格式
      @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")// 数据格式转换,并加上8小时进行存储
      esPathHandlerEntity.setTimestamp(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+0800").format(new Date()));
      esPathHandlerRepository.save(esPathHandlerEntity);
    

    上面的配置与kibana里配置时间选择使用“浏览器”时间是统一的


  • 相关阅读:
    thinkphp传递参数
    $this->display输出模板
    ConterReplaceBehavior.class.php模板内容替换,如__PUBLIC__
    Index/Common目录下文件
    thikphp创建共享数据config.php
    thinkphp连接数据库
    thinkphp笔记
    thinkphp安装 版本 3.1.3
    DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
    js倒计时
  • 原文地址:https://www.cnblogs.com/lori/p/15671417.html
Copyright © 2011-2022 走看看