Android Utililty Methods Date String Parse

List of utility methods to do Date String Parse

Description

The list of methods to do Date String Parse are organized into topic(s).

Method

StringconvertDateTimeStrFormat(String dateStr, String pattern, String newPattern)
convert Date Time Str Format
return DateTimeUtil.formatCalendar(
        DateTimeUtil.parseString(dateStr, pattern), newPattern);
DateconvertStringToDate(String strDate, String pattern)
convert String To Date
DateFormat df = new SimpleDateFormat(pattern, Locale.US);
Date date = null;
strDate = strDate.replace("T", " ");
try {
    date = df.parse(strDate);
} catch (ParseException e) {
    e.printStackTrace();
return date;
longparse(String pattern, String date)
parse
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
try {
    return sdf.parse(date).getTime();
} catch (ParseException e) {
    e.printStackTrace();
return 0;
Dateparse3339(String time)
parse
final Time t = new Time();
t.parse3339(time);
return new Date(t.toMillis(false));
DateparseDate(String date)
parse Date
try {
    return DATE_FORMATOR.parse(date);
} catch (Exception e) {
    return null;
longparseDate(String date)
parse Date
return parse(DATE_FORMAT, date);
DateparseDate(String rawDate)
parse Date
try {
    return PARSER_GRIND.parse(rawDate);
} catch (ParseException e) {
    return new Date();
StringparseDateStr(String dateStr, String srcPattern, String destPattern)
parse Date Str
if (isEmpty(dateStr)) {
    return null;
if (isEmpty(srcPattern)) {
    srcPattern = "yyyy-MM-dd HH:mm:ss";
if (isEmpty(destPattern)) {
    destPattern = "yyyy-MM-dd";
...
DateparseDateString(String dateStr, String pattern)
parse Date String
return parseDateString(dateStr, pattern, Locale.getDefault());
DateparseDateString(String dateStr, String pattern, Locale locale)
parse Date String
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, locale);
return dateFormat.parse(dateStr, new ParsePosition(0));