我有以下字符串“2015-04-02 11:52:00 + 02”,我需要在Java中将它解析为时间戳。 我试过各种格式,包括在java中的时间戳字符串到时间戳
SimpleDateFormat mdyFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+Z");
,但似乎没有任何工作 - 我不断收到一个ParseException
谁能帮助?
我需要这样的东西:
SimpleDateFormat mdyFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+Z");
Timestamp t = new Timestamp(mdyFormat.parse("2015-04-02 11:52:00+02").getTime());
张贴您的StackTrace! – 2015-04-02 14:18:05
线程“main”中的异常java.text.ParseException:Unparseable date:“2015-04-02 11:52:00 + 02” \t at java.text.DateFormat.parse(Unknown Source) \t at com .. ..... Main.main(Main.java:45) – Alexandr 2015-04-02 14:20:12
不知道你是否可以使用Java 8,但[这篇文章](http://stackoverflow.com/questions/22463062/how-to-parse-format -dates-with-localdatetime-java-8)可以帮助你。 – Pete 2015-04-02 14:38:49