Here you can find the source of calendarToString(Calendar calendar)
Parameter | Description |
---|---|
calendar | a parameter |
public static String calendarToString(Calendar calendar)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private static final SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy HH:mm"); /**/*w w w . j a va 2 s .c om*/ * Convert a Gregorian calendar object to string representation * @param calendar * @return the string representation or empty string if calendar is null */ //@author A0112115A public static String calendarToString(Calendar calendar) { if (calendar == null) { return ""; } return fmt.format(calendar.getTime()); } /** * Convert a Gregorian calendar object to string representation * with a given format * @param calendar * @return the string representation or empty string if calendar is null */ //@author A0112115A public static String calendarToString(Calendar calendar, SimpleDateFormat format) { if (calendar == null) { return ""; } return format.format(calendar.getTime()); } }