Current timestamp as filename in Java

前端 未结 7 1551

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

7条回答
  •  温柔的废话
    2021-02-03 17:48

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

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

提交回复
热议问题