Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private static SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String calendar2String(Calendar calendar) { if (calendar != null) { return format1.format(calendar.getTime()); } else { return ""; } } }