java - How can I set the program time in seconds? -
i want give programme time in java. how can time in seconds? program:
public static void main(string[] args) { long start = system.nanotime(); system.out.print(start); }
for illustration when run programme show 7955739220574 nano time. mean's 7955 second. time program!!!!!? give thanks you.
please note system.nanotime()
returns time in nanoseconds passed since arbitrary point in time, not origin of program. system.currenttimemillis()
give absolute time in milliseconds since unix epoch (jan 1, 1970).
if want measure duration of can do:
long starttime = system.nanotime(); // ... code beingness measured ... long estimatedtime = system.nanotime() - starttime;
... showed in docs linked. if want in seconds should split estimatedtime
1 billion.
java time
No comments:
Post a Comment