Here you can find the source of getCurrentDateByString(String datePattern)
public static String getCurrentDateByString(String datePattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String getCurrentDateByString(String datePattern) { return new SimpleDateFormat(datePattern).format(System.currentTimeMillis()); }/*from ww w . jav a2 s. c o m*/ public static String getCurrentDateByString(Date date, String datePattern) { return new SimpleDateFormat(datePattern).format(date); } public static long currentTimeMillis() { return getToday().getTime(); } public static String getTime() { return sdfTime.format(new Date()); } public static Date getToday() { return new Date(); } }