Results 1 to 6 of 6
  1. #1
    tnahsin is offline Member
    Join Date
    Mar 2014
    Posts
    8
    Rep Power
    0

    Default Covert time to seconds

    I am trying to convert time in seconds to hhmmss format.How do i get the minutes and seconds.
    Last edited by tnahsin; 04-08-2014 at 10:07 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: Covert time to seconds

    Use a SimpleDateFormat: SimpleDateFormat (Java Platform SE 7 )
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    tnahsin is offline Member
    Join Date
    Mar 2014
    Posts
    8
    Rep Power
    0

    Default Re: Covert time to seconds

    thanks but i got the logic

    Java Code:
    int hr=t/3600;
    int mm=t%3600;
    mm=mm/60;
    
    int ss=t%3600;
    ss=ss/60;
    
    int time=(hr*10000)+(mm*100)+ss;
    return time;

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Covert time to seconds

    Can you explain what the problem is? How does what you have posted relate to getting time in a String in the format you want?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default Re: Covert time to seconds

    Do you mean 'time' as a duration or as a stamp, a mark, somewhere in the eons?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,357
    Rep Power
    6

    Default Re: Covert time to seconds

    Am I missing something? I do believe the OP already answered his own question in post #3.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Time String to Seconds int
    By willemuk in forum New To Java
    Replies: 3
    Last Post: 03-07-2012, 07:22 PM
  2. Appending Seconds to Time
    By reach2sudhakar in forum New To Java
    Replies: 9
    Last Post: 10-15-2010, 10:00 AM
  3. Replies: 4
    Last Post: 09-09-2010, 12:15 PM
  4. getting time elapsed in seconds
    By ali_sakar in forum New To Java
    Replies: 3
    Last Post: 03-06-2009, 09:37 AM
  5. measuring time in nano seconds
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-06-2007, 01:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •