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.
TimeUnit is available in Java 1.5+. Prior to that you will have to roll your own conversion constants.
|
|
available on the web at: |
http://mindprod.com/jgloss/timeunit.html |
optional Replicator mirror
|
J:\mindprod\jgloss\timeunit.html | |
![]() |
Please email your
feedback for publication,
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 :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[72.44.48.122] |
|
| Feedback | You are visitor number 1. | |