如何在Java中以字符串格式获取当前时间戳? “yyyy.MM.dd.HH.mm.ss” [英] How to get current timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss"
本文介绍了如何在Java中以字符串格式获取当前时间戳? “yyyy.MM.dd.HH.mm.ss”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Java中获取字符串格式的时间戳? yyyy.MM.dd.HH.mm.ss
How to get timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss"
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Timestamp());
这是我所拥有的,但是Timestamp()需要参数...
This is what I have, but Timestamp() requires an parameters...
推荐答案
替换
new Timestamp();
与
new java.util.Date()
因为没有默认的构造函数href =http://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html> 时间戳
,或您可以使用以下方法:
because there is no default constructor for Timestamp
, or you can do it with the method:
new Timestamp(System.currentTimeMillis());
这篇关于如何在Java中以字符串格式获取当前时间戳? “yyyy.MM.dd.HH.mm.ss”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文