Hi all again! I began to make a program for a library that uses Date variables. I found out that the Date type is being deprecated as my compiler says. Si I'm updating it to Calendar. But I have a few questions: 1. Can I translate a String to a Calendar? 2. Can I know the difference (in days) between to Calendar variables? 3. Can I display a Calendar as "07/09/04" instead of "Thu Aug 19 18:07:00 CEST 2004"?
As an example, if I rent a book on 29th, August 2004 and today is 4th, September 2004... is there a way to get 6 days? In all operations I'd like to bypass the time, only working with the date.
2. Can I know the difference (in days) between to Calendar variables?
That work you'll have to do. Calendar has a getTimeInMillis() method. You can use it to find the difference in milliseconds between your two dates. Divide the difference by the number of milliseconds in a day and you have it.
Thanks for the replies! But is not there an easier method for comparing dates? With the Date type variables it's possible to do it easy, but working with Calendar I think it's a step back to calculate it in miliseconds...