Here you can find the source of formatSqlDateTime(Date value)
public static String formatSqlDateTime(Date value)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { public static final String PATTERN_SQL_DATETIME_FULL = "yyyy-MM-dd HH:mm:ss"; public static String formatSqlDateTime(Date value) { return formatDate(value, PATTERN_SQL_DATETIME_FULL, null); }/* w w w .jav a 2 s.co m*/ /** * format the date with the given pattern. * * @param value Date * @param pattern String the format pattern, for example, * SimpleDate.PATTERN_US_DATE * @param tz TimeZone if null,will use the server's default timezone * @return String the formated string */ public static String formatDate(Date value, String pattern, TimeZone tz) { if (value == null) { return ""; } SimpleDateFormat formater = new SimpleDateFormat(pattern, Locale.US); if (tz != null) { formater.setTimeZone(tz); } return formater.format(value); } }