Android Hour Format homiToString(int hour, int minute)

Here you can find the source of homiToString(int hour, int minute)

Description

homi To String

Declaration

public static String homiToString(int hour, int minute) 

Method Source Code

//package com.java2s;

public class Main {
    public static String homiToString(int hour, int minute) {
        String ho = "12";
        String mi = "00";
        String pmam = "AM";

        if (hour == 0) {
            ho = "12";
            mi = Integer.toString(minute);
            pmam = "AM";
        } else if (hour >= 1 && hour <= 11) {
            ho = Integer.toString(hour);
            mi = Integer.toString(minute);
            pmam = "AM";
        } else if (hour == 12) {
            ho = "12";
            mi = Integer.toString(minute);
            pmam = "PM";
        } else if (hour >= 13 && hour <= 23) {
            ho = Integer.toString(hour - 12);
            mi = Integer.toString(minute);
            pmam = "PM";
        } else if (hour == 24) {
            ho = "12";
            mi = Integer.toString(minute);
            pmam = "AM";
        }//from   w  w  w  .  j  av a 2 s  .  c o  m

        if (hour < 10) {
            ho = "0" + ho;
        }

        if (minute < 10) {
            mi = "0" + mi;
        }

        return ho + ":" + mi + " " + pmam;
    }
}

Related

  1. formatHour(int val)
  2. getReminderReadableTime(int hour, int minute)
  3. getCurrentHour()
  4. getDateByAddHour(String datetime, int minute)
  5. getDateByAddFltHour(float flt)
  6. formatElapsedTime(StringBuilder recycle, String format, long hours, long minutes, long seconds)
  7. time2String(int hour, int minute)