Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String getShortFormattedDate() { return getShortFormattedDate(System.currentTimeMillis()); } public static String getShortFormattedDate(long millis) { String resp = ""; try { resp = getShortFormattedDate(new Date(millis)); } catch (Exception ex) { } return resp; } public static String getShortFormattedDate(Date date) { String resp = ""; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); resp = sdf.format(date); } catch (Exception ex) { } return resp; } }