Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static String toYYYYMMDD(Calendar source) { if (source == null) { return "Can't toYYYYMMDDHHMMSS source null"; } int YYYY = source.get(Calendar.YEAR); int MM = source.get(Calendar.MONTH); int DD = source.get(Calendar.DAY_OF_MONTH); return YYYY + "-" + MM + "-" + DD; } }