java获取年份的后两位
public static String getDate(Date strDate) { String date = null; if (strDate!= null) { Calendar startTime = Calendar.getInstance(); int year = startTime.get(Calendar.YEAR) - 20; // 这里初始化时间,然后设置年份。只以年份为基准,不看时间 startTime.clear(); startTime.set(Calendar.YEAR, year); SimpleDateFormat formatter = new SimpleDateFormat("yyMM"); formatter.setLenient(false); formatter.set2DigitYearStart(startTime.getTime()); try { date = formatter.format(strDate); } catch (Exception e) { } } return date; }