How to find difference in time between two Date objects

Dear java experts ,
           Can somebody help me find the difference in time inthe form of STRING.
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a dd-MMM-yyyy");

Date Time1=sdf.parse(request.getParameter(time1).trim());
Date Time2=sdf.parse(request.getParameter(time2).trim());


I really want time 2 - time 1 in minutes and that too in STRING.

any help will be very highly apprecaiatted.
thanks,
testsubbu
TestsubbuAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
You can get millisend difference using:

long msecs = Time2.getTime() - Time1.getTime();

then divid it to get minutes:

long mins = msecs / (1000 * 60);

To convert to a String something like:

String s = mins+" minutes";
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.