Time format control front display

/**
     * Creation time
     */
    @Column(name = "CREATETIME")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createtime;

<result column="CREATETIME" property="createtime " jdbcType="TIMESTAMP" />


The same is true for the type in MySQL. The control database data is of this type. The
above ajax can be
placed in the model instead of ajax. Return use this
<%@ taglib prefix="fmt" uri="http: //java.sun.com/jsp/jstl/fmt" %>

<fmt:formatDate value='${roledetl.createtime}' pattern='yyyy-MM-dd HH:mm:ss' />




Second: not in model is returned by ajax, do not use it directly <fmt: The formatDate label

mysql time completely shows the `SENDER_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'SENDER_TIME'
in the table, in the map



<result column="SENDER_TIME" property="senderTime" jdbcType="TIMESTAMP" />

实体中
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//这种可以不要
  private Date senderTime;
 
 
  查询条件对时间传入处理
     @RequestMapping(value = "/queryPageMessage")
    @ResponseBody
    public PageInfo<Message> queryPageMessage(@RequestParam(value = "pageNo", required = false) int pageNo,
                                                        @RequestParam(value = "pageSize", required = false) int pageSize,
                                                        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") Date statTime,
                                                        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") Date endTime,
                                                         Message message
                                                        ) {

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326779852&siteId=291194637