Java examples for java.util:Time Format
get current Time in String in yyyyMMddHHmmssSSS format
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static void main(String[] argv) { System.out.println(getTimeStr()); }/*from w w w . j a v a2 s. c om*/ public static String getTimeStr() { DateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS"); Calendar calendar = Calendar.getInstance(); return df.format(calendar.getTime()); } }