List of utility methods to do Long Number to Time
String | getTimeFromLong(long diff) get Time From Long final String HOURS = "h"; final String MINUTES = "min"; final String SECONDS = "sec"; final long MS_IN_A_DAY = 1000 * 60 * 60 * 24; final long MS_IN_AN_HOUR = 1000 * 60 * 60; final long MS_IN_A_MINUTE = 1000 * 60; final long MS_IN_A_SECOND = 1000; Date currentTime = new Date(); ... |
long | getTimeLong() get Time Long return Long.parseLong(getTimeStr());
|
String | getTimeOf12(long time) get Time Of return getAmPm(time) + " " + getTimeStr(getHourOf12(time), getMinute(time), true); |
String | getTimeOld(long time) get Time Old String str1 = ""; String str2 = ""; SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd"); Date date = new Date(time); str2 = format.format(date); Date newDate2 = new Date(date.getTime() - 7 * 24 * 60 * 60 * 1000); str1 = format.format(newDate2); return str1 + "~" + str2; ... |
Long | getTimestampDiff(Long old) get Timestamp Diff return new Date().getTime() - old; |
String | getTimeStr(long t) get Time Str SimpleDateFormat dt = new SimpleDateFormat("z_yyyy.MM.dd_hh.mm.ss"); dt.setTimeZone(TimeZone.getTimeZone("PST")); String dateStr = dt.format(new Date(t)); return dateStr; |
String | getTimeStr(long timeLong) get Time Str Date date = new Date(timeLong); String timeStr = new SimpleDateFormat("yyyyMMddHHmmss").format(date); return timeStr; |
String | getTimeString(long nanoTime) Get a human readable String of the given time-period. NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY); float time = nanoTime; time /= 1000000; String result = nf.format(time) + " ms"; if (time >= 1000) { time /= 1000; result += " (" + nf.format(time) + " sec)"; return result; |
String | getTimeString(long time) Given a time value in milliseconds, this method returns a human readable representation. if (time < 0) { return NOT_AVAILABLE_STR; } else { SimpleDateFormat dateFormat; TimeZone timeZone = TimeZone.getTimeZone("GMT"); Calendar calendar = Calendar.getInstance(timeZone); calendar.setTimeInMillis(time); if (calendar.get(Calendar.HOUR) >= 1) { ... |
String | getTimeTagged(long time, boolean round) Return a readable String of the amount of time since a provided time. DecimalFormat format = round ? new DecimalFormat("#") : new DecimalFormat("#.##"); if (getHours(time) >= 1) return format.format(getHours(time)) + "h"; else if (Double.valueOf(format.format(getMinutes(time))) >= 1) return format.format(getMinutes(time)) + "m"; else return format.format(getSeconds(time)) + "s"; |