You can first parse the strings using the DateFormat.parse() method to get
a Date object and then use the Date.getTime() method to return the # of
milliseconds from the epoch for each date.
Subtract the values returned by getTime().
Divide the result by (60 * 60 * 24 * 1000)  = (86400000) to get the # of
days difference.

Regards,

Richard


At 03:44 PM 12/13/2001 -0700, you wrote:
>Does someone have an example of how to calculate the date difference in java.
>
>For example I have these two dates
>date #1 [12/01/2001]
>date #2 [12/31/2002]
>
>How do I calculate the # of days apart from date #1 to date #2
>
>Need some guidiance~
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to