How to parse Date from HTTP Last-Modified header?

前端 未结 5 1999
孤街浪徒
孤街浪徒 2020-12-08 00:02

HTTP Last-Modified header contains date in following format (example):
Wed, 09 Apr 2008 23:55:38 GMT
What is the easiest way to parse java.util.

5条回答
  •  盖世英雄少女心
    2020-12-08 00:41

    java.time

    When using the new Java Date and Time API the code would simply be:

    ZonedDateTime zdt = ZonedDateTime.parse("Wed, 09 Apr 2008 23:55:38 GMT", DateTimeFormatter.RFC_1123_DATE_TIME);
    

    The DateTimeFormatter class pre-defines a constant for that particular format in RFC_1123_DATE_TIME. As the name suggests, RFC 1123 defines that format.

提交回复
热议问题