Java Minute Convert minuteToTime(int minute)

Here you can find the source of minuteToTime(int minute)

Description

minute To Time

License

Open Source License

Declaration

public static String minuteToTime(int minute) 

Method Source Code

//package com.java2s;

public class Main {
    public static String minuteToTime(int minute) {

        // find hour in quirky am/pm form
        int hour = minute / 60;
        boolean pm = false;
        if (hour >= 12) {
            hour -= 12;/*from ww  w  . j av a 2  s. c  om*/
            pm = true;
        }
        if (hour == 0) {
            hour = 12;
        }

        // convert minute value to double-digit text
        minute %= 60;
        String mtext = Integer.toString(minute);
        if (mtext.length() == 1) {
            mtext = '0' + mtext;
        }

        // return complete time text
        return Integer.toString(hour) + ':' + mtext + (pm ? 'p' : 'a');
    }
}

Related

  1. minutesToString(Integer minutes)
  2. minutesToTicks(double x)
  3. minutesToTicks(int minutes)
  4. minutesToTime(int inTime)
  5. minuteToMillis(long minute)
  6. onMinute(int minute)