List of utility methods to do Long to Date Convert
String | getTimeLabel(long time) Returns label for the time. return formatter.format(new Date(time)); |
String | getTimestampDatetime(long milliseconds) get Timestamp Datetime Date date = new Date(milliseconds); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); |
String | getUTCTimeFromElapsedTime(long elapsedTime) get UTC Time From Elapsed Time return formatter.format(new Date(System.currentTimeMillis() - (SystemClock.elapsedRealtime() - elapsedTime))); |
long | getUTCTimeFromLocalMillis(long localMillis) Convert a local timestamp into UTC time return localMillis + getTimeZoneOffsetInMillis();
|
String | getUTCandRelativeDateFromElapsedTime( long elapsedTime) get UT Cand Relative Date From Elapsed Time try { SimpleDateFormat formatter = new SimpleDateFormat("dd/HH:mm:ss"); int flags = android.text.format.DateUtils.FORMAT_ABBREV_RELATIVE; long curTime = System.currentTimeMillis(); long time = curTime - (SystemClock.elapsedRealtime() - elapsedTime); StringBuffer sb = new StringBuffer(); sb.append(formatter.format(new Date(time))); ... |
String | getUTCandRelativeDateFromElapsedTime( long elapsedTime) get UT Cand Relative Date From Elapsed Time try { int flags = android.text.format.DateUtils.FORMAT_ABBREV_RELATIVE; long curTime = System.currentTimeMillis(); long time = curTime - (SystemClock.elapsedRealtime() - elapsedTime); StringBuffer sb = new StringBuffer(); sb.append(formatter.format(new Date(time))); if (time <= curTime) { ... |
String | getUniversalDateStamp(long time) Get current time stamp in universal format Format: yyyy-mm-ddThh:mm:ssZ e.g.: 1999-09-09T13:10:40Z Calendar cal = Calendar.getInstance(); cal.setTime(new Date(time)); return getUniversalDateStamp(cal); |
String | getUpdateDateStr(long time) get Update Date Str SimpleDateFormat dateFormat = new SimpleDateFormat( UPDATE_TIME_FORMAT); Date d = new Date(time); return dateFormat.format(d); |
String | getUpdateTimeStr(long time) get Update Time Str SimpleDateFormat dateFormat = new SimpleDateFormat( UPDATE_TIME_STR_FORMAT); Date d = new Date(time); return dateFormat.format(d); |
int | getYear(long dateTimeMillis) get Year SimpleDateFormat format = new SimpleDateFormat("yyyy"); StringBuilder dateString = new StringBuilder( format.format(dateTimeMillis)); return Integer.parseInt(dateString.toString()); |