Android Utililty Methods Time Parse

List of utility methods to do Time Parse

Description

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

Method

booleanisRFC3339Date(String date)
is RFC Date
boolean ret = false;
try {
    if (date != null && date.length() > 0) {
        Time t = new Time();
        t.parse3339(date);
        ret = true;
} catch (TimeFormatException tfex) {
...
longparseTime(String time)
parse Time
return parse(TIME_FORMAT, time);
longparseTimeString(final String time)
Takes a string of the form [HH:]MM:SS[.mmm] and converts it to milliseconds.
String[] parts = time.split(":");
long result = 0;
int idx = 0;
if (parts.length == 3) {
    result += Integer.valueOf(parts[idx]) * 3600000L;
    idx++;
result += Integer.valueOf(parts[idx]) * 60000L;
...
Stringstr2Time(String str)
str Time
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("HH:mm").format(date);
return formatStr;
longstr2TimeMillis(String str)
str Time Millis
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();
return date.getTime();
voidtime(String tag)
time
times.put(tag, System.currentTimeMillis());
DatetoModifiedTimeDate(double modDouble)
to Modified Time Date
try {
    long mod = Math.round(modDouble * 1000);
    return new Date(mod);
} catch (Exception e) {
    return null;
DatetoModifiedTimeDate(String modified)
to Modified Time Date
@SuppressWarnings("unused")
long now = System.currentTimeMillis();
try {
    double modDouble = Double.parseDouble(modified) * 1000;
    long mod = Math.round(modDouble);
    return new Date(mod);
} catch (Exception e) {
    return new Date(); 
...
StringtoStandardTime(String compactTime)
to Standard Time
if (compactTime.trim().length() < 14) {
    return "";
} else {
    return String.format("%s-%s-%s %s:%s:%s",
            compactTime.substring(0, 4),
            compactTime.substring(4, 6),
            compactTime.substring(6, 8),
            compactTime.substring(8, 10),
...