Android Utililty Methods Hour Format

List of utility methods to do Hour Format

Description

The list of methods to do Hour Format are organized into topic(s).

Method

StringformatHour(String string)
format Hour
return (string.length() == 1) ? "0" + string : string;
StringformatHour(int val)
format Hour
return formatHour(String.valueOf(val));
StringgetReminderReadableTime(int hour, int minute)
get Reminder Readable Time
StringBuilder sb = new StringBuilder();
String period = " AM";
if (hour == 0) {
    hour = 12;
    period = " AM";
} else if (hour == 12) {
    period = " PM";
} else if (13 <= hour && hour <= 23) {
...
intgetCurrentHour()
get Current Hour
Calendar c = Calendar.getInstance();
return c.get(Calendar.HOUR_OF_DAY);
StringgetDateByAddHour(String datetime, int minute)
get Date By Add Hour
String returnTime = null;
Calendar cal = new GregorianCalendar();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date;
try {
    date = ft.parse(datetime);
    cal.setTime(date);
    cal.add(GregorianCalendar.MINUTE, minute);
...
StringgetDateByAddFltHour(float flt)
get Date By Add Flt Hour
int addMinute = (int) (flt * 60);
Calendar cal = new GregorianCalendar();
cal.setTime(new Date());
cal.add(GregorianCalendar.MINUTE, addMinute);
return getFormatDateTime(cal.getTime(), "yyyy-MM-dd HH:mm:ss");
StringhomiToString(int hour, int minute)
homi To String
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) {
...
StringformatElapsedTime(StringBuilder recycle, String format, long hours, long minutes, long seconds)
Fast formatting of h:mm:ss
if (FAST_FORMAT_HMMSS.equals(format)) {
    StringBuilder sb = recycle;
    if (sb == null) {
        sb = new StringBuilder(8);
    } else {
        sb.setLength(0);
    sb.append(hours);
...
Stringtime2String(int hour, int minute)
Convert integer hour and minute to string format
return String.format("%02d", hour) + ":"
        + String.format("%02d", minute);