Java examples for java.util:Time Format
generate Unique String from current time in yyyyMMdd_HHmmss format
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) { System.out.println(generateUniqueString()); }//from www .j a v a 2s .co m public static String generateUniqueString() { DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); Date date = new Date(); return dateFormat.format(date); } }