Here you can find the source of formatTime(Date date)
public static String formatTime(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatTime(Date date) { String dateString = date.toString(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm"); try {/* w w w.ja v a2 s. c o m*/ dateString = formatter.format(date); } catch (IllegalArgumentException iae) { iae.printStackTrace(); } return dateString; } }