Date today=new Date();
System.out.println(today.toLocaleString());
显示结果:
2008-01-13 09:10:22
本文演示了如何使用Java获取当前日期时间并将其打印出来。通过创建Date对象并利用toLocaleString()方法,可以方便地得到格式化的日期时间字符串。
Date today=new Date();
System.out.println(today.toLocaleString());
显示结果:
2008-01-13 09:10:22
1913
1157

被折叠的 条评论
为什么被折叠?