Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Need Help for Java Coding in setting duration for parking system.

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation 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.


  2. #2
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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.

  3. #3
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Need Help for Java Coding in setting duration for parking system.

    Quote Originally Posted by hanggha View Post
    ...
    ...

    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 View Post
    ...need ... help
    How about showing some code?



    Cheers!

    Z

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default 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
    Improving the world one idiot at a time!

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Need Help for Java Coding in setting duration for parking system.

    Improving the world one idiot at a time!

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need Help for Java Coding in setting duration for parking system.

    merged

Similar Threads

  1. [SOLVED] Setting field width System.out.printf
    By ranjithfs1 in forum Java Theory & Questions
    Replies: 3
    Last Post: March 18th, 2012, 01:55 PM
  2. Replies: 2
    Last Post: February 19th, 2012, 07:36 AM
  3. Laugh parking garage
    By madhusanka in forum What's Wrong With My Code?
    Replies: 16
    Last Post: April 20th, 2011, 09:21 AM
  4. I want to extract minutes and seconds from duration
    By msa969 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 02:14 PM
  5. Parking Lot Program help!
    By soul.salem in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 23rd, 2011, 10:35 PM