Here you can find the source of dateToString(Date data, String format)
public static String dateToString(Date data, String format) throws Exception
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateToString(Date data, String format) throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat(format); StringBuilder dateString = new StringBuilder(dateFormat.format(data)); return dateString.toString(); }/* w w w . java 2 s. c om*/ public static String dateToString(Date data) throws Exception { return dateToString(data, "dd/mm/yyyy"); } }