Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Find Number of days between two given dates

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 86
    Comment on it

    Here, I am writing simple method to find out the number of days between two dates.


    In many situations, we need to calculate it. So just pass two dates as parameters of the method and get the number of days in long data type.


     
    

    public long getDateDiffString(Date date1, Date date2) { long time1 = date1.getTime(); long time2 = date2.getTime(); long aDay = 1000 * 60 * 60 * 24; long noOfDays = (time2 - time1) / aDay;

    if (noOfDays > 0) { return noOfDays; } else { noOfDays *= -1; return noOfDays; } }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: