Here you can find the source of DateToStringSQL(Date date, String separador)
public static String DateToStringSQL(Date date, String separador)
//package com.java2s; import java.sql.Date; import java.util.Calendar; public class Main { public static String DateToStringSQL(Date date, String separador) { if (date == null) { return null; }/*from ww w. j a v a 2s.co m*/ Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int dia = calendar.get(Calendar.DAY_OF_MONTH); String stringDia = dia < 10 ? "0" + dia : String.valueOf(dia); int mes = calendar.get(Calendar.MONTH) + 1; String stringMes = mes < 10 ? "0" + mes : String.valueOf(mes); int ano = calendar.get(Calendar.YEAR); String dataEmString = ano + separador + stringMes + separador + stringDia; return dataEmString; } }