The code snippet below gets and prints timestamp in SQL format.

Java Code:
java.util.Date today = new java.util.Date();
java.sql.Timestamp now = new java.sql.Timestamp(today.getTime());
		
System.out.println(now);
Output:

Java Code:
2008-02-10 11:33:16.64