Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

NX: How to solve "48 hours" ?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
yanjun wang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!