Here you can find the source of getCurrentDateToString(String pattern)
Parameter | Description |
---|---|
pattern | a parameter |
public static String getCurrentDateToString(String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//from www . j a v a 2 s .co m * add by zhaoliguo format current date to string by input pattern * * @param pattern * @return String */ public static String getCurrentDateToString(String pattern) { Date date = new Date(); return getDateToString(date, pattern); } /** * add by zhaoliguo format date to string by input pattern * * @param date * @param pattern * @return String */ public static String getDateToString(Date date, String pattern) { SimpleDateFormat format = new SimpleDateFormat(pattern); String returnDate = format.format(date); return returnDate; } }