Current timestamp as filename in Java
You can get the current timestamp appended with a file extension in the following way:
String fileName = new Date().getTime() + ".txt";
No need to get too complicated, try this one liner:
String fileName = new SimpleDateFormat("yyyyMMddHHmm'.txt'").format(new Date());
try this one
String fileSuffix = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());