Here you can find the source of timestamp(Calendar date)
public static String timestamp(Calendar date)
//package com.java2s; //License from project: GNU General Public License import java.text.DecimalFormat; import java.util.Calendar; public class Main { public static String timestamp(long millis) { Calendar date = Calendar.getInstance(); date.setTimeInMillis(millis);/* w ww . ja v a 2 s .c om*/ return timestamp(date); } public static String timestamp(Calendar date) { DecimalFormat format = new DecimalFormat("00"); int month = date.get(Calendar.MONTH) + 1; int day = date.get(Calendar.DAY_OF_MONTH); int hour = date.get(Calendar.HOUR_OF_DAY); int minute = date.get(Calendar.MINUTE); int second = date.get(Calendar.SECOND); return "" + date.get(Calendar.YEAR) + format.format(month) + format.format(day) + format.format(hour) + format.format(minute) + format.format(second); } }