当前时间戳作为 Java 中的文件名 [英] Current timestamp as filename in Java

查看:46
本文介绍了当前时间戳作为 Java 中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用当前时间戳命名由我的 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?

推荐答案

不用太复杂,试试这一款:

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

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

这篇关于当前时间戳作为 Java 中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆