Parse DIFFERENT RSS pubDate to Date object in java
i understood how to format the date according to this link parse exemple
but my problem is a 开发者_JS百科bit complex i have different pubDate rss elements for example
Sun, 21 Aug 2011 20:19:47 +0200 or
Sun, 21 Aug 2011 10:01
what is the best why to set one format for any pubDate element
RSS pubDate must conform to the RFC 822 Date/Time specification. You can use the same DateFormat
object from your parsing link to get the proper string from a java Date
.
DateFormat formatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
String pubDateText = formatter.format(pubDate);
Where pubDate is a previously defined Date object. This will always return the same format.
精彩评论