zoukankan      html  css  js  c++  java
  • mybatis的Date类型。

    在写select的时候,里面的查询语句。where后面如果jdbcType=DATE没有写的话是 这个形式的。

    <select id="selectPhoto" parameterType="com.jbj.bean.Photo" resultType="java.lang.Integer">
             select count(p.p_id),b.buildname from photo p
                inner join buildinfo b
                on p.p_b_id =b.id
                where b.id=#{pbId}
                and date_format(p.p_time,'%Y-%m-%d')=#{pTime}
        </select>

    写上后: 

    #{pTime,jdbcType=DATE}

    知识点2:

    创建的日期。是从1900-01-00开始的。  下面的例子是2018-04-16

    Date date=new Date(2018-1900,04-01,16);

     知识点3:

    在实体中加上注解:

    @DateTimeFormat(pattern = "yyyy-MM-dd")
        private Date pTime;

     知识点4:

        返回的JSON数据是从1970年1月1日至今的毫秒数。

        

    解决方案:

        在对应的属性的set方法上加上注解。

        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        public void setDate(Date date) {
          this.date = date;
        }

        

  • 相关阅读:
    BF算法和KMP算法
    Python课程笔记 (五)
    0268. Missing Number (E)
    0009. Palindrome Number (E)
    0008. String to Integer (atoi) (M)
    0213. House Robber II (M)
    0198. House Robber (E)
    0187. Repeated DNA Sequences (M)
    0007. Reverse Integer (E)
    0006. ZigZag Conversion (M)
  • 原文地址:https://www.cnblogs.com/bulrush/p/8857956.html
Copyright © 2011-2022 走看看