Android Date String to Date Convert ParseUTCDate(String str)

Here you can find the source of ParseUTCDate(String str)

Description

Parse UTC Date

Declaration

public static Date ParseUTCDate(String str) 

Method Source Code

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static Date ParseUTCDate(String str) {
        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ssZ", Locale.CHINA);
        try {/*w  w  w  .j a v a2 s  . c o  m*/
            Date date = formatter.parse(str);

            return date;
        } catch (ParseException e) {
            try {
                SimpleDateFormat formatter2 = new SimpleDateFormat(
                        "EEE, dd MMM yyyy HH:mm:ss Z", Locale.CHINA);
                Date date2 = formatter2.parse(str);

                return date2;
            } catch (ParseException ex) {
                return null;
            }
        }
    }
}

Related

  1. ParseDate(String str)
  2. formatToDate(String date)
  3. fromStringFR(String dateString)
  4. fromStringUS(String dateString)
  5. getDateFromString(String dateString, String dateFormat)