Java examples for java.sql:Timestamp
The following code shows how to get Time Stamp.
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Locale; public class Main { public static void main(String[] argv) { System.out.println(getTimeStamp()); }/*from ww w . j a v a 2 s.com*/ public static String getTimeStamp() { String rtnStr = null; String pattern = "yyyyMMddhhmmssSSS"; try { SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA); Timestamp ts = new Timestamp(System.currentTimeMillis()); rtnStr = sdfCurrent.format(ts.getTime()); } catch (Exception e) { throw new RuntimeException(e); } return rtnStr; } }