This content has been marked as final. Show 3 replies
1 sec = 1000 millisec
so divide the result by 1000 to get the seconds
long elapsedTimeSecond = elapsedTimeMillis / 1000; // total # of seconds
long elapsedTimeMillis = elapsedTimeMillis % 1000; // total number of millis left
System.out.println("Seconds = " + elapsedTimeSecond + " millis = " + elapsedTimeMillis);
use the Calendar, DateFormat SimpleDateFormat class to convert time and date stuff ..
brgds Per Fisker
Hello people,But that output time in millis corresponds to about December 24 last year, so I doubt very much that is the difference between end and start1 unless you started the program at the epoch (1970) (before java existed!). Maybe thats why you asked such an apparently stupid question because the obvious answer of dividing by 1000 was not going to yield an answer anywhere within cooey of what you might expect your answer to be.
I just started learning java, I have a little problem
that I can't seem to solve. I have a small program
that outputs milliseconds. But I want to convert this
milliseconds to seconds, this is where am having
this is a segment of the code.
long start1 = System.currentTimeMillis();
long end = System.currentTimeMillis();
long elapsedTimeMillis = end - start1 ;
and i got an output like this: 1072215156330.
Hopefully this solves your problem rather than just answering your question.
but, how do i convert this output into seconds.
Please help me out guys and have a great holiday.