datetime - How to calculate difference between two date(date object) in Java -
this question has answer here:
i have 2 date in form as:
date1 = tue jan 01 00:00:00 npt 2013 date2 = tue sep 30 00:00:00 npt 2014
now need find difference between these 2 dates.
how can in java or in groovy.
convert dates miliseconds , operate 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)
Comments
Post a Comment