I have two date in form as:
date1 = Tue Jan 01 00:00:00 NPT 2013
date2 = Tue Sep 30 00:00:00 NPT 2014
Now I need to find the difference between these two dates.
How can I do this in Java or in Groovy.
I have two date in form as:
date1 = Tue Jan 01 00:00:00 NPT 2013
date2 = Tue Sep 30 00:00:00 NPT 2014
Now I need to find the difference between these two dates.
How can I do this in Java or in Groovy.
Convert your dates to miliseconds and operate with them:
long diffInMills = date2.getTime() - date1.getTime();
in seconds
diffInMills / 1000
in minutes
diffInMills / (1000*60)
in hours
diffInMills / (1000*60*60)
in days
diffInMills / (1000*60*60*24)