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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -