Java 将时间戳转换为字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26360974/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert timestamp to string
提问by user3703289
In java I need to display 'time of the program start'
在java中我需要显示“程序启动时间”
It must be in String
.
它必须在String
.
How do I get the current time, and then convert it to a String
?
如何获取当前时间,然后将其转换为String
?
采纳答案by amit bhardwaj
回答by S. Tersteeg
new Date().toString();
新日期().toString();
http://www.mkyong.com/java/java-how-to-get-current-date-time-date-and-calender/
http://www.mkyong.com/java/java-how-to-get-current-date-time-date-and-calender/
Dateformatter can make it to any string you want
Dateformatter 可以把它变成你想要的任何字符串