效果图:

代码:
1、将下面内容copy到对应的controller类中;
/*
* 将时间戳转换为时间
*/
public String stampToDate(String s) {
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long lt = new Long(s);
Date date = new Date(lt);
res = simpleDateFormat.format(date);
return res;
}
2、然后在post请求方法中去拿到时间字符串。
//拿到时间字符串,说明:people是你自己项目中对应的实体类
people.setDate(stampToDate(System.currentTimeMillis()+""));
3、成功啦!!!

本文介绍了一种将时间戳转换为可读日期格式的方法,并演示了如何在Java代码中实现这一功能。通过使用SimpleDateFormat和Date类,我们可以轻松地将毫秒级时间戳转换成如'yyyy-MM-dd HH:mm:ss'这样的日期格式。
1960

被折叠的 条评论
为什么被折叠?



