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;
    }

 

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-02-27
猜你喜欢
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
相关资源
相似解决方案