Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getCurrentDateTimeForFile() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); Calendar cal = Calendar.getInstance(); String currentDateTimeForFile = dateFormat.format(cal.getTime()); return currentDateTimeForFile; } }