List of utility methods to do Time Different
int | getTimeDiffMin(String format, String startDate, String endDate) get Time Diff Min Date sDate = null; Date eDate = null; int ret = 0; int sign = 1; try { sDate = (new SimpleDateFormat(format)).parse(startDate); Calendar cal1 = Calendar.getInstance(); cal1.setTime(sDate); ... |
boolean | isDateDiff_2(String pattern, String time2, String time1) is Date Dif_ Date d1 = parse(pattern, time1); Date d2 = parse(pattern, time2); long diff = d2.getTime() - d1.getTime(); if (diff > 0) { return true; return false; |
Boolean | isLowerThanMinTimeDiff(Date lastUpdate, Date now, Long minTimeDiff) is Lower Than Min Time Diff long diffinDays = diffInDays(lastUpdate, now); Boolean resultValue = minTimeDiff < diffinDays; return resultValue; |
Long | printTimeDiff(Long oldDate, Long newDate, String message) print Time Diff System.out.println(message + ": " + (newDate - oldDate)); return newDate; |
void | printTimeDiffNano(String message, long start) print Time Diff Nano System.out.println(String.format("message: %s duration: %d", message, System.nanoTime() - start));
|
String | timeDiff(Calendar calenndarCurrentTime, Calendar calenndarStartTime) time Diff long startTime = calenndarStartTime.getTimeInMillis(); long currentTime = calenndarCurrentTime.getTimeInMillis(); SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); long elapsed = currentTime - startTime; return dateFormat.format(new Date(elapsed)); |
Date | timeDiff(Date salida, Date llegada) time Diff long m1 = toMinutes(salida); long m2 = toMinutes(llegada); long dif = Math.abs(m2 - m1); Date fecha = toDate(dif * 60); return fecha; |