我无法使用java I将1715 gmt转换为本地/gmt类型。
temptime= "1715UTC"
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" HH:mm");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date myDate = simpleDateFormat.parse(temptime);
time= Long.toString(myDate.getTime()); 但是我得到了java.text.ParseException:无法解释的日期:“1715年”,请帮我整理一下
发布于 2017-01-19 09:18:29
你的格式错了。您有HHmm格式,而不是HH:mm格式
这是修改过的代码
String temptime= "1715UTC";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HHmm");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date myDate = simpleDateFormat.parse(temptime);
long time= Long.toString(myDate.getTime()); 下面是一个具有类似代码的意为,它以具有正确输出(17:15)的字符串格式显示结果。
https://stackoverflow.com/questions/41737684
复制相似问题