Automatic human readable time interval

Viewed 5853

I would like to express some time intervals in a human readable format. I was looking for a library automatically able to choose the correct size of the units. The intervals will range from milliseconds to weeks. Something like

  • 0.2s
  • 2:00
  • 4 days
  • ...

I know I could manually check the size of the argument and then convert it but before reinventing the wheel I wanted to ask if there is a (standard) library to achieve that.

  • TimeUnit does the conversions but there is no knowledge about the size of the argument
  • a Joda-Time Duration represents exactly what I need but I did not find much about representation (but for the ISO8601 formatting of ReadableDuration)

Edit:

My input in in nanoseconds and output as described above.

1 Answers
Related