Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static final SimpleDateFormat sequenceFormat = new SimpleDateFormat("yyyyMMddHHmmss"); public static String getDefaultFormat() { return getDateFormat(sequenceFormat); } public static String getDateFormat(DateFormat df) { return getDateFormat(System.currentTimeMillis(), df); } public static String getDateFormat(long time, DateFormat df) { Date d = new Date(time); return df.format(d); } }