javatimestamp

Current timestamp as filename in Java


I want to name new files created by my Java application with the current timestamp.

I need help with this. How do I name the new files created with the current timestamp? Which classes should I include?


Solution

  • No need to get too complicated, try this one liner:

    String fileName = new SimpleDateFormat("yyyyMMddHHmm'.txt'").format(new Date());