Here you can find the source of getDateTime()
public static String getDateTime()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getDateTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(new Date()); }//from w w w .j av a 2s . co m public static java.sql.Timestamp getDateTime(String sDt) { try { return java.sql.Timestamp.valueOf(sDt); // sDt // format:yyyy-mm-dd // hh:mm:ss.fffffffff } catch (IllegalArgumentException iae) { sDt = sDt + " 00:00:00"; try { return java.sql.Timestamp.valueOf(sDt); } catch (Exception e) { return null; } } } }