parse string to Date in EEE, d MMM yyyy HH:mm:ss Z format - Android java.util

Android examples for java.util:Date Format

Description

parse string to Date in EEE, d MMM yyyy HH:mm:ss Z format

Demo Code

import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    private static SimpleDateFormat PARSER_GRIND = new SimpleDateFormat(
            "EEE, d MMM yyyy HH:mm:ss Z", Locale.US);
    public static Date parseDate(String rawDate) {
        try {/*from   www  . j  a  v a  2 s . c  o  m*/
            return PARSER_GRIND.parse(rawDate);
        } catch (ParseException e) {
            return new Date();
        }
    }

}

Related Tutorials