Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Giving current timestamp as folder name in java

Tags:

java

directory

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.

like image 666
abhay sachu Avatar asked Sep 12 '26 12:09

abhay sachu


1 Answers

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();
like image 169
Icy Creature Avatar answered Sep 14 '26 01:09

Icy Creature



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!