Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String DateToServerFormat() { String str = null; String outputPattern = "yyyy-MM-dd"; try { Calendar c = Calendar.getInstance(); SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern); str = outputFormat.format(c.getTime()); } catch (Exception e) { e.printStackTrace(); } return str; } }