Here you can find the source of formatDateTime(Calendar time)
public static String formatDateTime(Calendar time)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String formatDateTime(Calendar time) { if (time == null) { return ""; }// w w w. j av a 2 s . com DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return df.format(time.getTime()); } }