Java Minute Get getTimeFromMinutes(final int minutes)

Here you can find the source of getTimeFromMinutes(final int minutes)

Description

Turn the int minutes into a 4 digit String hours and minutes value

License

Apache License

Parameter

Parameter Description
minutes int

Return

String 4 digit hours + minutes

Declaration

public static String getTimeFromMinutes(final int minutes) 

Method Source Code

//package com.java2s;
/* ********************************************************************
 Licensed to Jasig under one or more contributor license
 agreements. See the NOTICE file distributed with this work
 for additional information regarding copyright ownership.
 Jasig licenses this file to you under the Apache License,
 Version 2.0 (the "License"); you may not use this file
 except in compliance with the License. You may obtain a
 copy of the License at://w  ww.j a v a2 s.  c  o  m
    
 http://www.apache.org/licenses/LICENSE-2.0
    
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on
 an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied. See the License for the
 specific language governing permissions and limitations
 under the License.
 */

public class Main {
    /** Turn the int minutes into a 4 digit String hours and minutes value
     *
     * @param minutes  int
     * @return String 4 digit hours + minutes
     */
    public static String getTimeFromMinutes(final int minutes) {
        return pad2(minutes / 60) + pad2(minutes % 60);
    }

    /** Return String value of par padded to 2 digits.
     * @param val
     * @return String
     */
    private static String pad2(final int val) {
        if (val > 9) {
            return String.valueOf(val);
        }

        return "0" + String.valueOf(val);
    }
}

Related

  1. getRawMinutes(int m)
  2. getRemainingMinutes(final long ms)
  3. getRemainingMinutes(int minutes)
  4. getReminderMinutes(int option)
  5. getSecondsByMinutes(int minutes)
  6. getTimeInEpoch(int offSetInMinutes)
  7. getTimeInMinuteResolution(long timeMillis)
  8. getTimeInMinutes(final String duration)
  9. getWholeMinutes(double coordinate)