【发布时间】:2012-11-06 15:16:47
【问题描述】:
发布的日期字符串返回为:Sun,2012 年 11 月 18 日 06:50:02 GMT,我的 convertDate 方法返回 java.text.ParseException: Unparseable date: "Sun, 18 Nov 2012 06:50:02 GMT”(偏移量 8)。我检查了资源,但找不到像这样有用的资源...Parsing a String with a GMT timezone to Date using SimpleDateFormat
如果您能对此有所了解,将不胜感激。这是我的方法.. 此处发布日期为星期日,2012 年 11 月 18 日 06:50:02 GMT
public Date convertDate(String pubDate){
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MM yyyy hh:mm:ss Z",Locale.US);
Date newsDate = new GregorianCalendar(0, 0, 0).getTime();
try{
newsDate = sdf.parse(pubDate);
}catch(ParseException e){
Log.d(Tag, "Exception Parsing date" + pubDate);
}
return null;
}
【问题讨论】: