Here you can find the source of getCurrentTimeForFileName()
public static String getCurrentTimeForFileName()
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getCurrentTimeForFileName() { SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy_HHmmssS"); Date timeStr = Calendar.getInstance().getTime(); return formatter.format(timeStr); }/* w w w .j av a2s .c om*/ public static String getTime(Date executionTime) { SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); return formatter.format(executionTime); } public static Date getTime(String timeInString) { DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss"); Date date = null; try { date = dateFormat.parse(timeInString); // System.out.println("Date and Time: " + date); } catch (Exception e) { e.printStackTrace(); } return date; } }