abhay sachu abhay sachu - 6 months ago 18
Java Question

Giving current timestamp as folder name in java

As we can give the current time as file name in java , can we do the same with folders too?
Can we give the name of the folder as current time stamp?
please help.Thank You.

Answer

yes something like this.

Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("hh mm ss");
String time = dateFormat.format(now);
File dir = new File(time);
dir.mkdir();
Comments