Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String DATEFORMAT_NORMAL = "yyyy-MM-dd HH:mm:ss"; public static String format(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT_NORMAL); return sdf.format(date); } public static String format(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }