Java Utililty Methods Minute

List of utility methods to do Minute

Description

The list of methods to do Minute are organized into topic(s).

Method

intnumberOfMinutesForDays(int days)
number Of Minutes For Days
return 60 * 24 * days;
StringrefineHourMinute(String timeString)
Prepare the a user-entered time string to represent "hours:minutes".
String ret = timeString.replace('.', ':');
ret = ret.replaceAll("^(\\d):", "0$1:");
ret = ret.replaceAll(":(\\d)$", ":0$1");
return ret;
intsamplesToMinutes(int sampleRate, int samples)
Calculates how many minutes samples are with sampleRate.
return Math.round(((float) samples / sampleRate) / 60.0f);
longsecsToMinutes(long secs)
secs To Minutes
return secs / SECONDS_IN_MINUTE;
longselectOfToday(int hour, int minute, int second, int millisecond)
select Of Today
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, second);
calendar.set(Calendar.MILLISECOND, millisecond);
Date date = calendar.getTime();
return date.getTime();
intshortTimeToMinutes(String time)
short Time To Minutes
return Integer.parseInt(time.substring(0, 2)) * 60 + Integer.parseInt(time.substring(3, 5));
booleansleepToNextMinute()
sleep To Next Minute
try {
    long current = System.currentTimeMillis();
    Thread.sleep(ONE_MINUTE - current % ONE_MINUTE + 500);
    return true;
} catch (InterruptedException e) {
    return false;
StringTimeDeltaString_JustMinutesSecs(long ms)
Time Delta Strin Just Minutes Secs
int secs = (int) (ms / 1000 % 60);
int mins = (int) (ms / 1000 / 60 % 60);
return String.format("%02dm %02ds", mins, secs);
StringtimeFromMinutes(Long minutes)
Converts a time interval from minutes to a minutes/hours time string.
I.E.: 123 > "2 h 3 min", 45 > "45 min"
if (minutes > 60) {
    Long hours = (long) Math.floor(minutes / 60);
    minutes -= hours * 60;
    return hours + " h " + minutes + " min";
} else
    return minutes + " min";
inttoXMinutes(float t)
to X Minutes
t = t / 60;
return (int) (t);