1. //比较两个字符串日期相差的天数
  2. //1秒=1000毫秒 
  3. public int compDate(String bigDate,String smallDate){   int day = 0;  
  4. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");  
  5. try {  
  6. //将"yyyy-mm-dd"字符串格式的日期转换为java.util.Date型  
  7. Date bigDay = sdf.parse(bigDate);  
  8. Date smallDay = sdf.parse(smallDate);  
  9. day = (int)((bigDay.getTime()-smallDay.getTime())/3600/24/1000);  
  10. catch (ParseException e) {  
  11. e.printStackTrace();  
  12. }  
  13. return day;