List of utility methods to do Long Number to Time
String | getTimeText(Long oldTime) get Time Text Date old = parseDate(oldTime, TimeFormat);
return formatTime(old);
|
String | getUploadPath(String fileName, long time) get Upload Path SimpleDateFormat formater = new SimpleDateFormat("yyyy/MM/dd"); String uploadPath = "/upload/" + formater.format(new Date()) + "/" + time + getFileExt(fileName); File dir = new File(getWebRoot() + uploadPath); if (!dir.exists()) { try { dir.mkdirs(); } catch (Exception e) { e.printStackTrace(); ... |
void | logDuration(Logger logger, Level level, long startTime, String message) log Duration final long duration = System.currentTimeMillis() - startTime; logger.log(level, message + " [Duration = " + duration + "ms]"); |
String | long2Str(long time) long Str synchronized (date) { date.setTime(time); return sdf.format(date); |
String | longToPgnDate(long time) [Date "2009.10.07"] return PGN_HEADER_DATE_FORMAT.format(new Date(time)); |
String | longToTimedDate(long time) Convent a long value into a date containing a time-stamp SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return sdf.format(Long.valueOf(time)); |
String | prettyDate(long time) pretty Date long diff = (System.currentTimeMillis() - time) / 1000; double day_diff = Math.floor(diff / 86400); if (day_diff == 0 && diff < 60) return "just now"; if (diff < 120) return "1 minute ago"; if (diff < 3600) return Math.floor(diff / 60) + " minutes ago"; ... |
void | printDuration(String message, long startTime) print Duration String duration = formatDuration(stopDuration(startTime)); System.out.println(message + ": " + duration + " sec"); |
void | printExecutionTime(long startTime, long endTime, String className, String methodName) Prints the execution time of a current running method in seconds. DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); long runningTime = (endTime - startTime) / 1000; System.err.println("INFO: " + dateFormat.format(cal.getTime()) + " " + className + " " + methodName + " run for " + (runningTime == 1 ? runningTime + " second." : runningTime + " seconds.")); |
long | str2Long(String time) str Long if (time == null || time.isEmpty()) { return System.currentTimeMillis(); synchronized (sdf) { try { date = sdf.parse(time); } catch (ParseException e) { return Date.parse(time); ... |