Here you can find the source of getTodayTimeForDB()
public static String getTodayTimeForDB() throws Exception
//package com.java2s; //License from project: GNU General Public License import java.text.FieldPosition; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getTodayTimeForDB() throws Exception { return getDate(new Date(), "yyyy/MM/dd HH:mm:ss"); }/*from w ww. ja v a 2s . c om*/ public static String getDate(Date pDate, String pFormat) { if (pDate == null) return ""; StringBuffer ret = new StringBuffer(); new SimpleDateFormat(pFormat).format(pDate, ret, new FieldPosition(0)); return ret.toString(); } public static Date getDate(String strDate, String pFormat) throws Exception { if (strDate == null) return null; return new SimpleDateFormat(pFormat).parse(strDate, new ParsePosition(0)); } }