开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜