Java Calendar Minute getMinute(Calendar cal)

Here you can find the source of getMinute(Calendar cal)

Description

get Minute

License

Open Source License

Declaration

public static String getMinute(Calendar cal) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {

    public static String getMinute(Calendar cal) {
        return strLen(String.valueOf(cal.get(Calendar.MINUTE)), 2);
    }/* w w w.  j av a 2  s.  c o m*/

    public static int getMinute(String s) {
        if (s == null || s.length() < 16) {
            return 0;
        }
        return Integer.parseInt(s.substring(14, 16));
    }

    private static String strLen(String s, int len) {
        if (isNullStr(s)) {
            s = "";
        }
        if (s.length() == 8) {
            return s;
        }
        for (int i = 0; i < len - s.length(); i++) {
            s = "0" + s;
            if (s.length() == 8) {
                break;
            }
        }
        return s;
    }

    private static boolean isNullStr(String s) {
        if (s == null || s.trim().length() <= 0) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. calendarTodayOf(int hour, int minute, int second, int millis)
  2. clearHoursMinutesSecondsMillis(Calendar calendar)
  3. getFirstMinuteOfDay(Calendar dt)
  4. getMinutes(Calendar cal)
  5. getMinutes(Calendar cal1, Calendar cal2)
  6. getMinutes(String expression, Calendar time)
  7. getMinutesInterval(Calendar start, Calendar end)