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