Here you can find the source of addTimestampToFilename(String fileName)
public static String addTimestampToFilename(String fileName)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static final String fileTimestampFormat = "yyyy-MM-dd'T'HH.mm.ss.SSSZ"; public static String addTimestampToFilename(String fileName) { int pos = fileName.lastIndexOf('.'); String prefix = fileName; String suffix = ""; if (pos != -1) { prefix = fileName.substring(0, pos); suffix = fileName.substring(pos); }//from ww w . j a v a2 s .c o m String newFileName = prefix + timestampForFile() + suffix; return newFileName; } public static String timestampForFile() { String timeString = new SimpleDateFormat(fileTimestampFormat).format(System.currentTimeMillis()); return timeString; } }