Here you can find the source of date2String(Date source, String formatString)
public static String date2String(Date source, String formatString)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String date2String(Date source, String formatString) { return date2String(source, new SimpleDateFormat(formatString)); }// www. j a v a 2 s.co m public static String date2String(Date source, DateFormat format) { try { return format.format(source); } catch (Exception e) { return ""; } } }