当我运行下面的代码将时间字符串转换为Java日期时,它失败。如何在Java中使用偏移时间简单日期格式
String s = "04/17/2017 06:46:53 -600";
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss Z");
Date value = format.parse(s);
Exception in thread "main" java.text.ParseException: Unparseable date: "04/17/2017 06:46:53 -600"
at java.text.DateFormat.parse(Unknown Source)
什么是用于将日期字符串转换为java日期的正确格式字符串?
可能需要'-0600'不'-600' – AxelH
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#rfc822timezone – 1615903
请参阅http:// stackoverflow.com/questions/9541043/java-convert-string-to-date-in-with-time-zone-variable?rq=1 – 2017-04-20 11:48:15