Android Date String Parse parseYoutubeDate(String rawDate)

Here you can find the source of parseYoutubeDate(String rawDate)

Description

parse Youtube Date

Declaration

public static Date parseYoutubeDate(String rawDate) 

Method Source Code

//package com.java2s;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static Date parseYoutubeDate(String rawDate) {
        final String TAG = "StringUtil.parseYoutubeDate";
        String pattern = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US);
        String minusTimezone = rawDate.substring(0, rawDate.indexOf('.'));
        String cleanSpecials = minusTimezone.replace('T', ' ');

        try {//ww  w  . ja v a  2s.  c  om
            return sdf.parse(cleanSpecials);
        } catch (ParseException pe) {
            Log.e(TAG, "Error while parsing date: " + cleanSpecials
                    + " with pattern: " + pattern, pe);
            return null;
        }
    }
}

Related

  1. parseDateStr(String dateStr, String srcPattern, String destPattern)
  2. parseDateString(String dateStr, String pattern)
  3. parseDateString(String dateStr, String pattern, Locale locale)
  4. parseSimpleDate(String dateString)
  5. parseUTCFormattedDateString(String dateString)
  6. stringToDate(String str)
  7. toDate(String sdate)
  8. toDate(String sdate)
  9. toDateFormat(String d, String delim)