时间格式控制前边显示
时间格式控制前面显示
/**
* 创建时间
*/
@Column(name = "CREATETIME")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createtime;
<result column="CREATETIME" property="createtime" jdbcType="TIMESTAMP" />
MySQL中的类型也要如此,控制数据库数据是此类型
以上ajax即可
放在model中不是ajax return用这种
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate value='${roledetl.createtime}' pattern='yyyy-MM-dd HH:mm:ss' />
二:不在model中是ajax返回的,直接用不要<fmt:formatDate 标签
mysql时间完整显示
table中
`SENDER_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '发送时间',
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
) {
/**
* 创建时间
*/
@Column(name = "CREATETIME")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createtime;
<result column="CREATETIME" property="createtime" jdbcType="TIMESTAMP" />
MySQL中的类型也要如此,控制数据库数据是此类型
以上ajax即可
放在model中不是ajax return用这种
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate value='${roledetl.createtime}' pattern='yyyy-MM-dd HH:mm:ss' />
二:不在model中是ajax返回的,直接用不要<fmt:formatDate 标签
mysql时间完整显示
table中
`SENDER_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '发送时间',
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
) {