TimeUnit : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

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:

This page is posted
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 the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
no blog for this page
IP:[65.110.21.43]
Your face IP:[54.87.179.107]
You are visitor number