Java Duration Format formatDuration(int durationMins)

Here you can find the source of formatDuration(int durationMins)

Description

format Duration

License

Open Source License

Declaration

public static String formatDuration(int durationMins) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String formatDuration(int durationMins) {
        int minutes = durationMins % 60;
        int hours = (durationMins - minutes) / 60;
        return hours + ":" + String.valueOf(minutes % 60 + 100).substring(1, 3);
    }//  w w w .j a  va 2  s  .  c o  m

    public static String formatDuration(long durationMins) {
        long minutes = durationMins % 60;
        long hours = (durationMins - minutes) / 60;
        return hours + ":" + String.valueOf(minutes % 60 + 100).substring(1, 3);
    }

    public static String substring(String input, int maxLength) {
        if (input == null)
            return null;
        else
            return (input.length()) <= maxLength ? input : input.substring(0, maxLength);
    }
}

Related

  1. formatDuration(final Duration duration)
  2. formatDuration(final Duration duration, final boolean wrapInDurationFunction)
  3. formatDuration(final int duration)
  4. formatDuration(final long milliSeconds)
  5. formatDuration(final long seconds)
  6. formatDuration(int seconds)
  7. formatDuration(int seconds)
  8. formatDuration(long duration)
  9. formatDuration(long duration)