Search code examples
javaconverterstimeunit

Any lib to convert timeunit by amount of time?


Input unit is second, then output unit varies by amount of time.

example :

50 -> 50sec // less than a min
80 -> 1min 20sec
3700 -> 1hour 1min 40sec
216040 -> 30day 40sec
...

Is there any java lib that can do this?

It will be perfect if it suppors timeformat and i18n.


Solution

  • There are a couple of these mentioned in this famous java blog: http://www.mkyong.com/java/java-time-elapsed-in-days-hours-minutes-seconds/

    You can also get Joda on Github, I have used it earlier worked fine for me. https://github.com/JodaOrg/joda-time