您的位置:首页 > 编程语言 > Java开发

JAVA将字符串Sat Nov 25 2017 00:00:00 GMT+0800 (中国标准时间)转成标准时间

2017-12-13 11:21 567 查看
使用Spring MVC后台,需要接收前端传来的一个时间,时间格式如下:

Sat Nov 25 2017 00:00:00 GMT+0800 (中国标准时间)


刚开始使用如下的方式进行接收,发现无法接收到数据

@RequestMapping(value = "/queryResearchIndexByMemberIdAndLogDate",method = RequestMethod.GET)
public void queryByLogDate(Long memberId, Date logDate, HttpServletResponse response){
}




然后就想着,以字符串的方式进行接收,再将字符串转成Date格式。

@RequestMapping(value = "/queryResearchIndexByMemberIdAndLogDate",method = RequestMethod.GET)
public void queryByLogDate(Long memberId, String logDate, HttpServletResponse response){
}


SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd yyyy HH:mm:ss z", Locale.US);
try{
Date logDate1 = sdf.parse(logDate);
}catch(Exception e){
System.out.println(e.getMessage());
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: