Here you can find the source of date2Str(SimpleDateFormat date_sdf)
public static String date2Str(SimpleDateFormat date_sdf)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String date2Str(SimpleDateFormat date_sdf) { Date date = getDate();/*from w w w. j a v a 2 s . c o m*/ if (null == date) { return null; } return date_sdf.format(date); } public static String date2Str(Date date, SimpleDateFormat date_sdf) { if (null == date) { return null; } return date_sdf.format(date); } public static Date getDate() { return new Date(); } public static Date getDate(long millis) { return new Date(millis); } public static String getDate(String format) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }