1 23 package com.sun.enterprise.diagnostics.util; 24 25 import java.util.Calendar ; 26 import java.util.Date ; 27 31 public class UniqueNameGenerator { 32 33 private static final String AM = "AM"; 34 private static final String PM = "PM"; 35 private static final char SEPARATOR = '-'; 36 private static final char DATE_SEPARATOR = '_'; 37 private static final String REPORT_JAR = "report.jar"; 38 39 40 public UniqueNameGenerator() { 41 } 42 43 48 public static String getName(String target) { 49 Date dateObj = new Date (); 50 Calendar calendar = Calendar.getInstance(); 51 String am_pm = calendar.get(Calendar.AM_PM) == 0? AM : PM; 52 int month = calendar.get(Calendar.MONTH) + 1; 53 String dateValue = "" + month + 54 calendar.get(Calendar.DAY_OF_MONTH) + 55 calendar.get(Calendar.YEAR); 56 String dateTime = ""+calendar.get(Calendar.HOUR_OF_DAY) + 57 SEPARATOR + calendar.get(Calendar.MINUTE) + am_pm; 58 String fileName = target + SEPARATOR + 59 dateValue + DATE_SEPARATOR + dateTime + SEPARATOR + REPORT_JAR; 60 61 return fileName; 62 } 63 } 64 | Popular Tags |