In my instructions,there is : " They take bookings only within 48 hours of the start of room occupancy. ". I try to compare the system date and the record date. I have make them Date Object by "today = new Date();" and "formatter = new SimpleDateFormat("yyyy/MM/dd", currentLocale);". But when I try "int number = today.compareTo(testDay); ",the result is "number = 1" when today is after testDay. What I want to get is the concrete days between the two date. eg: 2004/02/09 - 2004/02/02 = 7(days). now 48 hours is two days long. How to get this? or any other solution? Appreciate for your comments....
compareTo never claimed that it returns the difference, only that it returns a positive number, 0, or negative number for greater, equal, or less than. To compare dates, convert them to their millisecond representation (e.g. date.getTime()), then subtract one from the other. Now you have the difference in milliseconds. There are a fixed number of milliseconds in a day (1000 * 60 * 60 * 24), so you should be able to calculate that.
Hi Yanjun, I got the UrlyBird and I read from other threads that you can side step this requirement of 48 hours to a business requirement rather a system requirement. In another words, you may consider not implementing the validation and putting your justification in Choices.txt. Just for your information. I did that. Best Regards
posted 14 years ago
Billybob Marshall ,thank you very much! I have implemented in your way. It"s OK! Frankie Cha ,thank you for your very nice comments,I will document it in Choices.txt.