我在我的代码中使用SimpleDateFormat("dd-MMM-YYYY"),它输出错误.
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-YYYY");
System.out.println("Actual date : "+new Date()+" after Formatting : "+ dateFormat.format(new Date()));
Run Code Online (Sandbox Code Playgroud)
以上代码给出: 实际日期:Tue Dec 30 13:51:06 IST 2014格式化后:2015年12月30日
以上代码为打印日期,年份为1年.此问题仅适用于2014年12月28日至31日的日期.
提前致谢.--Ajay
java ×1