Asked • 03/16/19

How to convert Milliseconds to "X mins, x seconds" in Java?

I want to record the time using `System.currentTimeMillis()` when a user begins something in my program. When he finishes, I will subtract the current `System.currentTimeMillis()` from the `start` variable, and I want to show them the time elapsed using a human readable format such as "XX hours, XX mins, XX seconds" or even "XX mins, XX seconds" because its not likely to take someone an hour.What's the best way to do this?

1 Expert Answer

By:

Patrick B. answered • 03/17/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.