List of utility methods to do Long to Date Convert
long | getLocalTimeFromUTCMillis(long utcMillis) Convert a UTC timestamp into device local time return utcMillis - getTimeZoneOffsetInMillis();
|
long | getLongOfString(String date) get Long Of String String dateStr2 = date; ParsePosition pos2 = new ParsePosition(0); SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd"); Date strtodate2 = formatter2.parse(dateStr2, pos2); long dateLong2 = strtodate2.getTime(); return dateLong2; |
int | getMinute(long dateTimeMillis) get Minute SimpleDateFormat format = new SimpleDateFormat("mm"); StringBuilder dateString = new StringBuilder( format.format(dateTimeMillis)); return Integer.parseInt(dateString.toString()); |
int | getMinutesSinceStartOfDay(long milliseconds) get Minutes Since Start Of Day Calendar c = Calendar.getInstance(); c.setTimeInMillis(milliseconds); int hours = c.get(Calendar.HOUR); int ampm = c.get(Calendar.AM_PM); if (ampm == Calendar.PM) { hours += 12; int minutes = c.get(Calendar.MINUTE); ... |
int | getMonth(long dateTimeMillis) get Month SimpleDateFormat format = new SimpleDateFormat("MM"); StringBuilder dateString = new StringBuilder( format.format(dateTimeMillis)); return Integer.parseInt(dateString.toString()) - 1; |
String | getNameForDcim(long time) get Name For Dcim Date date = new Date(time); SimpleDateFormat dateFormat = new SimpleDateFormat( DATE_TIME_FORMAT_DCIM_FilENAME); return dateFormat.format(date); |
String | getNameForFile(long time) get Name For File Date date = new Date(time); SimpleDateFormat dateFormat = new SimpleDateFormat( DATE_TIME_FORMAT_DCIM_FilENAME); return dateFormat.format(date); |
long | getNumberOfDaysPassed(long date1, long date2) Returns the number of days passed between two dates. if (sThenTime == null) { sThenTime = new Time(); sThenTime.set(date1); int day1 = Time.getJulianDay(date1, sThenTime.gmtoff); sThenTime.set(date2); int day2 = Time.getJulianDay(date2, sThenTime.gmtoff); return Math.abs(day2 - day1); ... |
String | getReadableTimeStamp(long timeStamp) Generate file name from system time in the format "yyyy-MM-dd HH:mm:ss:SSS", return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.US) .format(new Date(timeStamp)); |
String | getReadableTimeUsage(long timeUsageMs) Format the time usage to string like "1d17h37m3s728ms" long millisecondsLeft = timeUsageMs % 1000; if (timeUsageMs == millisecondsLeft) { return millisecondsLeft + "ms"; long seconds = timeUsageMs / 1000; long secondsLeft = seconds % 60; if (secondsLeft == seconds) { return secondsLeft + "s" + millisecondsLeft + "ms"; ... |