Java

Java timestamp

2018-01-29  本文已影响4人  JaedenKil

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));
}
上一篇 下一篇

猜你喜欢

热点阅读