Return a java.sql.Timestamp equal to the current time in Java
Description
The following code shows how to return a java.sql.Timestamp equal to the current time.
Example
//from w w w. ja v a 2s . c o m
public class Main {
public static java.sql.Timestamp now() {
return new java.sql.Timestamp(new java.util.Date().getTime());
}
public static void main(String[] argv) {
System.out.println(now());
}
}
The code above generates the following result.