Here you can find the source of formatMinutes(long timeMinutes)
public static String formatMinutes(long timeMinutes)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatMinutes(long timeMinutes) { long days = timeMinutes / 60 / 24; long hours = timeMinutes / 60 % 24; long mins = timeMinutes % 60; StringBuilder sb = new StringBuilder(); boolean hasDays = days > 0; boolean hasHours = hours > 0; boolean hasMins = mins > 0; if (hasDays) { sb.append(days);/*w ww . j a v a2s.co m*/ sb.append(" day"); if (days != 1) sb.append('s'); } if (hasHours) { if (hasDays) { if (hasMins) sb.append(", "); else sb.append(" and "); } sb.append(hours); sb.append(" hour"); if (hours != 1) sb.append('s'); } if (hasMins) { if (hasDays || hasHours) sb.append(" and "); sb.append(mins); sb.append(" minute"); if (mins != 1) sb.append('s'); } else { if (!(hasMins || hasDays || hasHours)) return "0 minutes"; } return sb.toString(); } }