【发布时间】:2013-10-12 10:39:16
【问题描述】:
我需要以字符串形式获取当前年份值,所以我这样做了:
Calendar now = Calendar.getInstance();
DateFormat date = new SimpleDateFormat("yyyy");
String year = date.format(now);
它可以在 ubuntu 上运行,但不能在 Windows 7 上运行。
你知道为什么吗? 有没有更安全的方法来做到这一点?
谢谢
【问题讨论】:
-
“不工作”到底是什么意思?
标签: java calendar operating-system date-format