Android examples for java.util:Day
Get the time of day from a calendar to a string.
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static void main(String[] argv) { Calendar calendar = Calendar.getInstance(); System.out.println(convertToTimeString(calendar)); }//www . java 2 s .c o m /** * Get the time of day from a calendar to a string. * @param calendar The Calendar to convert. * @return The formatted time */ public static String convertToTimeString(Calendar calendar) { SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm aaa"); return timeFormat.format(calendar); } }