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

StringgetDateOffset(String date, int offset)
get Date Offset
Date tempDate = null;
if (date.indexOf("/") > 0)
    tempDate = getDateObj(date, "[/]");
if (date.indexOf("-") > 0)
    tempDate = getDateObj(date, "[-]");
tempDate = getDateAdd(tempDate, offset);
return getFormatDateTime(tempDate, "yyyy/MM/dd");
StringgetDateTomorrow(String date)
get Date Tomorrow
Date tempDate = null;
if (date.indexOf("/") > 0)
    tempDate = getDateObj(date, "[/]");
if (date.indexOf("-") > 0)
    tempDate = getDateObj(date, "[-]");
tempDate = getDateAdd(tempDate, 1);
return getFormatDateTime(tempDate, "yyyy/MM/dd");
StringconvertStandardDateTime(String time)
convert Standard Date Time
String standardResult = "";
try {
    time = time + "000";
    long tmpTime = Long.parseLong(time);
    SimpleDateFormat sdf = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss");
    standardResult = sdf.format(new Date(tmpTime));
} catch (Exception e) {
...
StringremoveTimeZone(String data)
remove Time Zone
return data.replaceFirst("(\\s[+|-]\\d{4})", "");
longparseFileName(String timeStr)
Parse system time from string in the format "yyyyMMdd-HHmmss-SSS",
return new SimpleDateFormat("yyyyMMdd-HHmmss-SSS", Locale.US)
        .parse(timeStr).getTime();
StringformatDate(String date)
format Date
SimpleDateFormat input = new SimpleDateFormat(INPUT_DATE_FORMAT);
SimpleDateFormat output = new SimpleDateFormat(
        "dd/MM/yyyy HH::mm:ss");
Date d;
try {
    d = input.parse(date);
    return output.format(d);
} catch (ParseException e) {
...
DatechangeStringToDate(String fecha, String pattern)
change String To Date
DateFormat formato = new SimpleDateFormat(pattern);
return formato.parse(fecha);
StringchangeStringToDate1(String str)
change String To Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date date6 = null;
try {
    date6 = sdf.parse(str);
    return date6.toString();
} catch (ParseException e) {
    e.printStackTrace();
    return "";
...
StringchangeStringToDate2(String str)
change String To Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date date6 = null;
try {
    date6 = sdf.parse(str);
    java.sql.Date date7 = new java.sql.Date(date6.getTime());
    return date7.toString();
} catch (ParseException e) {
    e.printStackTrace();
...
StringchangeStringToDate3(String str)
change String To Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date date6 = null;
try {
    date6 = sdf.parse(str);
    java.sql.Date date7 = new java.sql.Date(date6.getTime());
    Timestamp stamp9 = new Timestamp(date7.getTime());
    return stamp9.toString();
} catch (ParseException e) {
...