Do you know that Java developer Google for even simplest of things? Yes, that's true and I can say it because even I do that :-). The current timestamp value is one of them. In UNIX you can just use the date command to get the current date and time but how do you get that in your Java program? Well, you can get the current timestamp in Java by using Date and Timestamp class of JDK. Note, there is "s" instead of "S" in Timestamp. Since Date in Java contains both date and time, it can be used as Timestamp value as well but when you print Date, it shows time in the local timezone. If you need just the timestamp, then you need to convert the java.util.Date to java.sql.Timestamp. You can convert a Date to Timestamp by using the getTime() method which returns the number of millisecond from the Epoch.
Read more »