我試着去解析以下日期:日期與simpledateformatter解析
Wed Aug 27 13:08:45 +0000 2008
(是對Twitter的API 1.1)
我提出以下格式:
/**
* Large twitter date format sample: "Wed Aug 27 13:08:45 +0000 2008"
*/
private static final String LARGE_TWITTER_DATE_FORMAT = "EEE MMM dd HH:mm:ss Z yyyy";
但它說:
java.text.ParseException: Unparseable date: "Sun Dec 25 14:49:28 +0000 2011" (at offset 0)
at java.text.DateFormat.parse(DateFormat.java:626)
什麼即時做錯了?
謝謝
你的語言環境是什麼?換句話說,如果使用相同的'SimpleDateFormat'來格式化一個'new java.util.Date()',那麼哪種語言就是你得到的字符串。 – SJuan76
兩個日期字符串不匹配 - 異常中的一個和您要解析的日期字符串。請注意日期字符串中的奇數空白:任何前導空格? – pb2q
請參閱http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html – NagarjunaReddy