Java Parse Date Pattern YYYY parseRSSDate(String dateStr)

Here you can find the source of parseRSSDate(String dateStr)

Description

parse RSS Date

License

Open Source License

Declaration

public static final Date parseRSSDate(String dateStr) 

Method Source Code


//package com.java2s;
/*/*w  ww.ja  v a2  s.  c o  m*/
   Copyright ? 2013 Mael Le Gu?vel
   This work is free. You can redistribute it and/or modify it under the
   terms of the Do What The Fuck You Want To Public License, Version 2,
   as published by Sam Hocevar. See the COPYING file for more details.
*/

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    private static final String[] RSS_DATE_FORMATS = { "EEE, d MMM yy HH:mm:ss z", "EEE, d MMM yy HH:mm z",
            "EEE, d MMM yy", "EEE, d MMM yyyy HH:mm:ss z", "EEE, d MMM yyyy HH:mm z", "EEE, d MMM yyyy",
            "d MMM yy HH:mm z", "d MMM yy HH:mm:ss z", "d MMM yy", "d MMM yyyy HH:mm z", "d MMM yyyy",
            "d MMM yyyy HH:mm:ss z", "yyyy-MM-dd" };

    public static final Date parseRSSDate(String dateStr) {
        for (String format : RSS_DATE_FORMATS) {
            DateFormat formatter = new SimpleDateFormat(format, Locale.ROOT);
            try {
                Date date = formatter.parse(dateStr);
                return date;
            } catch (Exception e) {
            }
        }
        return null;
    }
}

Related

  1. parser(String strDate, String formatter)
  2. parserDate(String str)
  3. parseRegExcelNumber(String number)
  4. parseResponseDate(String date)
  5. parseRoundTripDateString(String roundTripString)
  6. parseSalesDate(final String ymd)
  7. parseSecureDate(final String dateString)
  8. parseSegKeyDate4Display(String source)
  9. parseSessionTime(String response)