Date Comparision


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Date Comparision

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    25

    Date Comparision

    What is the best way of comparing two dates in jsp?

    Need to know the number of days different between two dates.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    You could use the Calendar class' method getTimeInMillis() for the two dates,
    subtract them and divide the difference by number of milliseconds in 24 hrs. then add
    one day if the modulus of the division is > 0

    But I'm sure there are far more elegant ways to do this.

  3. #3
    Join Date
    Oct 2004
    Posts
    311
    You could try useing the Calendar.compareTo(Calendar) method. THis is supposed to return the number of milliseconds between the two calendar objects.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center