Home Ask Login Register

Developers Planet

Your answer is one click away!

clueless 99 February 2016

Create filename with date and time

Function Functions n Function Function Function


Dmitry Brant February 2016

You're looking for the SimpleDateFormat class: https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Try something like this:

SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); 
Date date = new Date();
String fileName = dt.format(date);

Post Status

Asked in February 2016
Viewed 2,186 times
Voted 8
Answered 2 times


Leave an answer

Quote of the day: live life