怎么判断给定一个日期是不是属于上个月的时间

如何判断给定一个日期是不是属于上个月的时间
如何判断给定一个日期是不是属于上个月的时间......
------解决方案--------------------


public static void main(String[] args) throws ParseException {
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(c.MONTH, -1);
SimpleDateFormat sf = new SimpleDateFormat("yyyyMM");
String lastMonth = sf.format(c.getTime()); //上个月的字符标示

System.out.println("请输入日期(以‘yyyy-MM-dd’格式):");
Scanner sc = new Scanner(System.in);
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd");
String strDate = sc.next();

Date date = dt.parse(strDate); //要判定的日期
if(lastMonth.equals(sf.format(date))){
System.out.println(true);
}else{
System.out.println(false);
}


}