Here you can find the source of dateFormatToString(String source, String format)
public static String dateFormatToString(String source, String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateFormatToString(String source, String format) { if (source == null || "".equals(source)) return null; SimpleDateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setLenient(false);/*www .j a v a 2 s. co m*/ return dateFormat.format(source); } public static String dateFormatToString(Date source, String format) { if (source == null || "".equals(source)) return null; SimpleDateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setLenient(false); return dateFormat.format(source); } }