How to convert minutes to Hours and minutes (hh:mm) in java

If your time is in a variable called t

int hours = t / 60; //since both are ints, you get an int
int minutes = t % 60;
System.out.printf("%d:%02d", hours, minutes);

It couldn’t get easier

Addendum from 2021:

Please notice that this answer is about the literal meaning of the question: how to convert an amount of minute to hours + minutes. It has nothing to do with time, time zones, AM/PM…

If you need better control about this kind of stuff, i.e. you’re dealing with moments in time and not just an amount of minutes and hours, see Basil Bourque’s answer below.

Leave a Comment