• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parking lot program question  RSS feed

 
Jack Bolton
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a Parking lot program, and i was thinking to ask the user for:
- arrival hour and
- exit hour.
so i could get the hours the car was in the Parking lot, but i just dont figure out, how to calculate how many hours was.
CAn I use the Date class or something like that?
thanks....
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can create Date or Calendar objects to represent the time in and time out. Then get time in milliseconds from each, subtract to get the difference and divide out hours, minutes and seconds for charging. There are quite a few API calls involved. Dig into the JavaDoc and see what you come up with. Post some code to let us know!

For grins, look into the TimeAndMoney package. It was designed for use in billing systems, I think, and may have some APIs that do just what you need.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!