Android Utililty Methods Time Get

List of utility methods to do Time Get

Description

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

Method

Stringnow()
now
Calendar cal = Calendar.getInstance();
return sDefaultDateFormat.format(cal.getTime());
StringgetCompactTime()
get Compact Time
Date curDate = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String result = sdf.format(curDate);
return result;
longgetCurrentEpochTime()
get Current Epoch Time
return new Date().getTime();
longgetCurrentTime()
get Current Time
Time t = new Time();
t.setToNow();
return t.toMillis(true);
StringgetDateTime()
get Date Time
SimpleDateFormat dateFormat = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Date date = new Date();
return dateFormat.format(date);
StringgetLongTime()
get Long Time
Date curDate = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmssSSS");
String result = sdf.format(curDate);
return result;
intgetRequestTime()
get Request Time
return requestTime;
StringgetSystemTime()
get System Time
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = df.format(c.getTime());
return formattedDate;
StringgetTime1()
get Time
java.util.Date date1 = new java.util.Date();
return date1.toString();
longgetTimeInMillis()
Method returns the current time as [local timezone] milliseconds.
return Calendar.getInstance().getTimeInMillis();