怎么样解决The method getYear() from the type Date is deprecated
2015-01-14
展开全部
那些方法都不推荐使用了,所以显示黄线,这样可以实现你想要的,你看下吧,希望对你有帮助
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int currenYear = calendar.get(Calendar.YEAR);
calendar.set(Calendar.YEAR, currenYear + 2);
java.sql.Date newDate = new java.sql.Date(calendar.getTimeInMillis());
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int currenYear = calendar.get(Calendar.YEAR);
calendar.set(Calendar.YEAR, currenYear + 2);
java.sql.Date newDate = new java.sql.Date(calendar.getTimeInMillis());
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询