Here you can find the source of getCurrentTimeForUseInAFileName()
public static String getCurrentTimeForUseInAFileName()
//package com.java2s; /**//from w ww. j a va 2s. c om * <p> * Utilities for manipulating Paths, Files, Directories, etc. * </p> * <p> * <span class="BSDLicense"> This software is distributed under the <a * href="http://hci.stanford.edu/research/copyright.txt">BSD License</a>.</span> * </p> * * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu) */ import java.text.DateFormat; import java.util.Calendar; public class Main { /** * @return The current time, with symbols replaced with underscores, so that we can use it in file names. * This is great for logs that have to be tagged with dates. */ public static String getCurrentTimeForUseInAFileName() { String time = DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()); // remove symbols that break Windows file names time = time.replaceAll(":", "_"); time = time.replaceAll(",", ""); return time; } }