Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

# of Days between dates

Status
Not open for further replies.

tmryan

Programmer
Dec 22, 2000
73
US
Kind of new to Java - pardon the newbie question.
I've created a form that has a couple of input fields and a button. The goal is to prompt for two dates and display the number of days between the two. I've been playing around with java.util.Date - but haven't figured it out yet. In the DB language I primarily use - dates are stored as the number of days since 01/01/1900. Is there a similar way to do this in Java?

Thanks Tim Ryan
PROGRESS Developer
 
I think you need to switch over to javascript which can help you doing the form validations and other issues
 
Yes there is. In the class java.util.Date, there is this method getTime() that returns the number of milliseconds since January1 as a long type.

You can get the long value of the 2 date and subtract them and convert the difference from milliseconds to day.

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top