Java Utililty Methods Second to Minute

List of utility methods to do Second to Minute

Description

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

Method

StringsecondsToHoursMinutesSeconds(final long secs)
Converts seconds into hours:minutes:seconds.
final double minutesRemaining = (secs / 60) % 60;
final double hoursRemaining = Math.floor(secs / 60 / 60);
final double secondsRemaining = secs % 60;
final StringBuilder sb = new StringBuilder();
if (hoursRemaining > 0.0) {
    sb.append((int) hoursRemaining);
    sb.append(" hrs, ");
if (minutesRemaining > 0.0) {
    sb.append((int) minutesRemaining);
    sb.append(" mins, ");
sb.append((int) secondsRemaining);
sb.append(" secs");
return sb.toString();
StringsecondsToMinutes(int s)
seconds To Minutes
int m = s / 60;
int ss = s % 60;
return align(m) + ":" + align(ss);
StringsecondsToMinutes(int seconds)
Converts seconds into minutes
int ms = seconds / 60;
int ss = seconds % 60;
String m = (ms < 10 ? "0" : "") + ms;
String s = (ss < 10 ? "0" : "") + ss;
return m + ":" + s;
intsecondsToMinutes(int seconds)
seconds To Minutes
if (seconds == 0) {
    return 0;
} else {
    int minutes = seconds / 60;
    if (seconds % 60 > 0) {
        minutes += 1;
    return minutes;
...
StringsecondsToMinutes(int time)
seconds To Minutes
if (time < 0)
    return null;
int minutes = (time / 60) % 60;
String minutesStr = (minutes < 10 ? "0" : "") + minutes;
return minutesStr;
inttimeToMinute(String time)
time To Minute
int mark = time.indexOf(':');
if (mark > 0) {
    int hour = Integer.parseInt(time.substring(0, mark));
    if (hour == 12) {
        hour = 0;
    String mins = time.substring(mark + 1, time.length() - 1);
    int minute = Integer.parseInt(mins);
...
inttimeToMinutes(String in)
Convert a time String to a time code in minutes
int mins;
if (in.length() == 8 && in.charAt(2) == ':' && in.charAt(5) == ':') {
    mins = (in.charAt(0) & 0xF) * 600 + (in.charAt(1) & 0xF) * 60 + (in.charAt(3) & 0xF) * 10
            + (in.charAt(4) & 0xF);
} else {
    mins = 0;
return mins;
...
StringtoDecimal(long seconds, int nanoseconds)
to Decimal
StringBuilder sb = new StringBuilder(20).append(seconds).append('.');
if (nanoseconds == 0L) {
    if (seconds == 0L) {
        return "0.0";
    sb.append("000000000");
} else {
    StringBuilder nanoSB = new StringBuilder(9);
...
StringtoDecimal(long seconds, int nanoseconds)
to Decimal
StringBuilder string = new StringBuilder(Integer.toString(nanoseconds));
if (string.length() < 9)
    string.insert(0, ZEROES, 0, 9 - string.length());
return seconds + "." + string;
inttoMinutes(int hour, int minutes)
to Minutes
hour = (hour < 0) ? 0 : hour;
minutes = (minutes < 0) ? 0 : minutes;
return ((hour * 60) + minutes);