Java examples for java.util:Minute
Gets hour and minute out of the calendar and converts it into a String.
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { Calendar calendar = Calendar.getInstance(); System.out.println(getCalendarTimeAsString(calendar)); }/*ww w. ja v a 2 s . c o m*/ /** * Gets hour and minute out of the calendar and converts it into a String. * @param calendar object, where you want the time from. * @return String of the time. */ public static String getCalendarTimeAsString(Calendar calendar) { String timeString = ""; timeString += calendar.get(Calendar.HOUR_OF_DAY); timeString += ":"; int minute = calendar.get(Calendar.MINUTE); if (minute < 10) { timeString += "0" + minute; } else { timeString += minute; } return timeString; } }