Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String PATTERN_ONE = "yyyy-MM-dd"; public static String getFormatDate(long timemillis) { return new SimpleDateFormat(PATTERN_ONE).format(new Date(timemillis)); } public static String format(Date date, String pattern) { String returnValue = ""; if (date != null) { SimpleDateFormat df = new SimpleDateFormat(pattern); returnValue = df.format(date); } return (returnValue); } }