DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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.

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links