Here you can find the source of dateDiffWithNow(Calendar sDate)
public static long dateDiffWithNow(Calendar sDate)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static long dateDiffWithNow(Calendar sDate) { Date now = Calendar.getInstance().getTime(); long timeDiff = now.getTime() - sDate.getTimeInMillis(); return timeDiff; }//from w ww.j a v a 2 s . c om public static long dateDiffWithNow(Date sDate) { Date now = Calendar.getInstance().getTime(); long timeDiff = now.getTime() - sDate.getTime(); return timeDiff; } public static long dateDiffWithNow(long sDate) { Date now = Calendar.getInstance().getTime(); long timeDiff = now.getTime() - sDate; return timeDiff; } public static String getTime(Date executionTime) { SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); return formatter.format(executionTime); } public static Date getTime(String timeInString) { DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss"); Date date = null; try { date = dateFormat.parse(timeInString); // System.out.println("Date and Time: " + date); } catch (Exception e) { e.printStackTrace(); } return date; } }