Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** * Turns a Java date object into a mySQL acceptable date string * * @param date * Date object * @return mySQL acceptable date string */ public static String toSQLDateTimeString(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(date); } }