List of utility methods to do Date Difference
Date | parseParamDate(final String diff) parse a string to get absolute date final String dateString = "0000-01-01T00:00:00.000UTC"; final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"); final char[] dateChars = dateString.toCharArray(); String timeZone = "UTC"; final String[] units = diff.split("[.]"); for (final String unit : units) { if (unit.matches("[YMDhms][0-9]+") || unit.matches("[Z]...")) { final char unitdesc = unit.charAt(0); ... |
long | timeDiff(Calendar date1, Calendar date2) time Diff long diff = date1.getTimeInMillis() - date2.getTimeInMillis(); return diff; |
String | timeDiffHourMinSec(Date start, Date end) time Diff Hour Min Sec Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(start); long startTime = calendar.getTimeInMillis(); calendar.setTime(end); long endTime = calendar.getTimeInMillis(); long diff = endTime - startTime; long seconds = (diff / 1000) % 60; long minutes = (diff / (60 * 1000)) % 60; ... |