This code can be used to print time line and generate timestamp:
private static void printTimestamp() {
Long ts = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
Date date = new Date(ts);
System.out.println("Date: " + sdf.format(date));
System.out.println("Timestamp: " + sdf2.format(date));
}
网友评论