# Need Help for Java Coding in setting duration for parking system.

• June 23rd, 2013, 07:15 PM
hanggha
Need Help for Java Coding in setting duration for parking system.
Hello,
I Need Help for Java Coding in setting duration for parking system.
the case is when changing the Day at 12 PM to 1 AM.

Example
Normal duration: Car in - 08.00 PM
Car Out - 09.30 PM
Duration - 1.30

Problem when changing the date
: Car in - 12.00 PM
: Car out - 1.30 AM
: Duration - 10.30 (The actually duration is 1.30

This is my problem I really need your help. Thanks.
• June 23rd, 2013, 07:30 PM
hanggha
Java Coding in setting duration for parking system.
Hello,
I Need Help for Java Coding in setting duration for parking system.
the case is in changing the Day at 12 PM to 1 AM.

Example
Normal duration: Car in - 08.00 PM
Car Out - 09.30 PM
Duration - 1.30

Problem when changing the date
: Car in - 12.00 PM
: Car out - 1.30 AM
: Duration - 10.30 (The actually duration is 1.30

This is my problem I really need your help. Thanks.
• June 23rd, 2013, 11:51 PM
Zaphod_b
Re: Need Help for Java Coding in setting duration for parking system.
Quote:

Originally Posted by hanggha
...
...

Problem when changing the date
: Car in - 12.00 PM
: Car out - 1.30 AM
: Duration - 10.30 (The actually duration is 1.30
...

Ummm...

11.59 PM is the last minute before midnight
12.00 AM is midnight (one minute later than 11.59 PM).
12.01 AM is one minute past midnight

11.59 AM is the last minute before noon
12.00 PM is noon (one minute later than 11.59 AM).
12.01 PM is one minute after noon.

Therefore: If in-time is 12.00 PM (noon) and out-time is 1.30 AM, the elapsed time is 13.30 (assuming it's the very next day).

I mean, in genera,l you have to keep track of the date also. (What if in-time is 12.30 AM on Sunday, 23 June, and out-time is 1.30 AM on Monday, 24 June?)

Quote:

Originally Posted by hanggha
...need ... help

Cheers!

Z
• June 24th, 2013, 12:09 AM
Junky
Re: Java Coding in setting duration for parking system.
It depends upon how you are calculating the duration. If you subtract the entry hour from the exit hour (including any carry over) an you get a negative value simply add 12.
Example:
Entry 11:00pm
Exit 2:00am
Duration is 3 hours. But if you subtract 11 from 2 you get -9. Then add 12 to get 3 hours.

--- Update ---

http://www.javaprogrammingforums.com...ng-system.html

Duplicate post
• June 24th, 2013, 12:10 AM
Junky
Re: Need Help for Java Coding in setting duration for parking system.
• June 24th, 2013, 12:30 AM
jps
Re: Need Help for Java Coding in setting duration for parking system.
merged