LoginSignup
0
0

More than 5 years have passed since last update.

RSS2.0のpubDateをJava8のDateTimeでparseする

Last updated at Posted at 2016-08-14

RSS2.0のpubDateの日付の形式はRFC822らしい。(仕様

時刻にはオフセットが付いてたりするので、java8のOffsetDateTimeを使うとして、RFC822の改訂版のRFC1123のDateTimeFormatterを使えば良い。

コードはこんな感じ。

String pubDate = "Sun, 14 Aug 2016 16:23:05 +0900"; // RFC822
OffsetDateTime dt = OffsetDateTime.parse(pubDate, DateTimeFormatter.RFC_1123_DATE_TIME);

System.out.println(dt.format(DateTimeFormatter.RFC_1123_DATE_TIME)); // Sun, 14 Aug 2016 16:23:05 +0900
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0