Difference between 2 dates!!
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Akshay_B
Posted On:   Thursday, October 6, 2005 02:37 PM

K,.. I need some help.

Problem :

I am retrieving a date from MS ACCESS, which is stored in the format of MM/dd/yyyy. Now,.. i want to find difference between this date and the current date. How do i do it?

PLease reply

Re: Difference between 2 dates!!

Posted By:   archna_vish  
Posted On:   Friday, October 7, 2005 04:52 AM

Hi Akshay !

Try this out:




String fromDB="10/01/2005";


String[] dateElts=fromDB.split("/");



Date compareWith=new Date(Integer.parseInt(dateElts[2])-1900,Integer.parseInt(dateElts[0])-1,Integer.parseInt(dateElts[1]));


Date today=new Date();


System.out.println(today);


System.out.println(compareWith);


System.out.println(today.after(compareWith));



fromDB indicates the date retrieved from MS Access (mm/dd/yyyy).

Re: Difference between 2 dates!!

Posted By:   Anonymous  
Posted On:   Friday, October 7, 2005 02:22 AM

http://forum.java.sun.com/thread.jspa?threadID=494373&messageID=2328581

http://javaalmanac.com/egs/java.util/CompDates.html



--------------------

Jeff Parker

www.devsquare.com

DevSquare - Online Application Development
About | Sitemap | Contact