How can I get the year, month, day, hours, minutes, seconds and milliseconds of the current moment in Java? I would like to have them as Strings
.
Or use java.sql.Timestamp. Calendar is kinda heavy,I would recommend against using it in production code. Joda is better.
import java.sql.Timestamp;
public class DateTest {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(new Timestamp(System.currentTimeMillis()));
}
}