Take a look at the javadocs on java.util.Date and java.util.Calendar. Chances are you'll also want to work with java.util.GregorianCalendar (the Gregorian calendar being the one the western world lives on).
-----Original Message----- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of syed huda Sent: Thursday, December 13, 2001 3:29 PM To: [EMAIL PROTECTED] Subject: Re: date difference Is there any way to get the difference in year, month, day format? ----- Original Message ----- From: "Richard Yee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 13, 2001 4:18 PM Subject: Re: date difference > 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 > =========================================================================== 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
