Android Utililty Methods Date String to Date Convert

List of utility methods to do Date String to Date Convert

Description

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

Method

DateconvertDateStringToDate(String dateString)
convert Date String To Date
SimpleDateFormat dateFormat = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
return dateFormat.parse(dateString);
Datestring2Date(String s, String s1)
string Date
Date date = new Date();
try {
    String s2 = stringNull(s1);
    SimpleDateFormat simpledateformat = new SimpleDateFormat(s2);
    String s3 = stringNull(s);
    date = simpledateformat.parse(s3);
} catch (Exception exception) {
return date;
DatestringToDate(SimpleDateFormat dateFormat, String dateToConvert, boolean catchError)
string To Date
try {
    Date localDate = dateFormat.parse(dateToConvert);
    return localDate;
} catch (Throwable localThrowable) {
    if (!catchError) {
        return new Date(1000L + System.currentTimeMillis());
return null;
DatestringToDate(String paramString1, String paramString2, boolean paramBoolean)
string To Date
SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(
        paramString2, Locale.getDefault());
localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone(TimeZone
        .getDefault().getID()));
try {
    Date localDate = localSimpleDateFormat.parse(paramString1);
    return localDate;
} catch (Throwable localThrowable) {
...
DatetoDate(String s)
Parses the date string and returns the date value.
Date date = null;
try {
    SimpleDateFormat sdf = new SimpleDateFormat(
            "dd.MM.yyyy HH:mm:ss");
    date = sdf.parse(s);
} catch (ParseException e) {
    e.printStackTrace();
return date;
DatetoDateFromString(String dateString)
to Date From String
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date date = new Date();
try {
    date = sd.parse(dateString);
} catch (ParseException e) {
    e.printStackTrace();
return date;
...
Stringstr2Date(String str)
str Date
SimpleDateFormat sdf = new SimpleDateFormat(
        "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
Date date = null;
try {
    date = (Date) sdf.parse(str);
} catch (ParseException e) {
    e.printStackTrace();
String formatStr = new SimpleDateFormat("yy-MM-dd").format(date);
return formatStr;
Stringglobal2Date(String str)
global Date
SimpleDateFormat sdf = new SimpleDateFormat(
        "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
Date date = null;
try {
    date = (Date) sdf.parse(str);
} catch (ParseException e) {
    e.printStackTrace();
String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
        .format(date);
System.out.println(formatStr);
return formatStr;