【发布时间】:2016-07-19 16:14:12
【问题描述】:
我有以下字符串:
2016 年 7 月 19 日 07:00:00 UTC
并正在使用以下代码将其转换为时间戳。但是控制台抛出以下错误:
java.text.ParseException:无法解析的日期:“2016 年 7 月 19 日 07:00:00 UTC”(偏移量 2)
代码:
String time = todayAt7;
DateFormat sdf = new SimpleDateFormat("hh:mm:ss");
try {
Date date = sdf.parse(time);
System.out.println("Date and Time: " + date);
} catch (Exception e1) {
e1.printStackTrace();
}
基本上我正在尝试找出“今天早上 7 点”的时间戳,有没有我想念的方法来做到这一点?
【问题讨论】:
-
世界标准时间 2016 年 7 月 19 日 07:00:00 你今天是什么时候?