import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class WorkTime{
public static void main(String[] args){
Date date=new Date();//获得当前日期
Calendar cal=Calendar.getInstance();
cal.setTime(date);
int year = cal.get(Calendar.YEAR);//获得年份
int month = cal.get(Calendar.MONTH);//获得月份
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dateStringToParse = "2005-10-30";
try{
Date d = bartDateFormat.parse(dateStringToParse);
cal.setTime(d);
int year2 = cal.get(Calendar.YEAR);
int month2 = cal.get(Calendar.MONTH);
int t = year - year2;//得到年差
int m = month -month2;//得到月差
if(m
System.out.println(ex.getMessage());
}
}
}