In Java, I have a long integer representing the time period in milliseconds. The time period can be from a few seconds to several weeks. I would like to output this time period as a string with the corresponding block.
For example, 3,000 should be displayed as "3 seconds," 61,200,000 should be displayed as "17 hours," and 1,814,400,000 should be displayed as "3 weeks."
Ideally, I could also fine-tune the formatting of the sub-blocks, for example. 62,580,000 can be displayed as "17 hours, 23 minutes."
Are there any existing Java classes that handle this?
source
share