TimeUnit : Java Glossary

TimeUnit

Humans like to measure time in variety of units including nanoseconds, microseconds, seconds, hours, days, weeks, months, years and centuries. For computation it is best to convert your times and time durations to a common unit, do your calculations, then convert back into whatever units the user likes. The most common units to work with are the millisecond used by System.currentTimeMillis, Date, Calendar, and days used by BigDate. You can roll your own conversions or you can use java.util.concurrent.TimeUnit that came in with Java version 1.5. Here are the various conversion factors you will need, both created from scratch and via TimeUnit.

TimeUnit always rounds down when converting units.

You may not specify long delay = TimeUnit.SECONDS .toMillis( 3.5 ); The parameter is always a long not a double.

Learning More

TimeUnit is available in Java 1.5+. Prior to that you will have to roll your own conversion constants.

Oracle’s Javadoc on TimeUnit class : available:

CMP homejump to top

available on the web at:

http://mindprod.com/jgloss/timeunit.html
  

optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\timeunit.html
logo
Please email your , letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email. If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, especially when sending an ad-hominem attack, a rant composed mainly of obscenities or a death threat, please quote the offending passage and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. I can’t very well fix erroneous or ambiguous text if I can’t find it.
Blog
IP:[65.110.21.43]
Your face IP:[72.44.48.122]
You are visitor number 1.