I have the following lines of code in my application:

return "Service is alive since: " + TimeUnit.MILLISECONDS.toMinutes(mxBean.getUptime()) + " minutes";

It uses the following package:

import java.util.concurrent.TimeUnit;

My application is a web application. Does it means that I have something wrong logically if I use something from concurrent package at a web application?

  • As an old hardened C/C++ programmer I have to wonder at Java people who import code which has function names longer than the math required to do it inline. ms/1000/60 isn't it?
    – Zan Lynx
    Sep 5, 2013 at 22:01

2 Answers 2


Using TimeUnit.MILLISECONDS.toMinutes(...) is fine as it doesn't actually invoke any threading behaviour (which would be incorrect in a Java EE container). It's part of core Java, so no overheads.


I can't see any problem with this, and in fact using TimeUnit.MILLISECONDS.toMinutes(...) was the solution to the SO question that I found when googling "java convert milliseconds to minutes".

If you were in a constrained environment where you were worried about the size of your deployment, you might need to try cutting out any packages or jars that you don't need, but since java.util.concurrent is part of core Java, removing it would take some work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.