Results 1 to 2 of 2

Thread: Format milliseconds

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Los Angeles
    Posts
    45

    Format milliseconds

    How do you format a number of milliseconds into hours, minutes, & seconds? Example, if I have a time of 67149 milliseconds, how can I change that into 1 min 7 secs??

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    I think you can do it like this. I tried to format from currentTimeMillis(); but i was having trouble. I just woke up and i need my daily caffeine fix.

    import java.util.Date;
    import java.text.DateFormat;


    class Timer{
    public static void main(String[] args){

    // returns the current time in milliseconds since midnight GMT
    // January 1,1970 GMT
    //long end = System.currentTimeMillis();

    DateFormat longTime = DateFormat.getTimeInstance(DateFormat.LONG);
    String time = longTime.format(new Date());
    System.out.println(time);
    }
    }

Posting Permissions

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



Click Here to Expand Forum to Full Width