你可以先把日期转换成毫秒然后通过两个日期的差得到一个毫秒数换算一下就得到月了,不过要取舍一下,多少天算一个月,比如:1个月20天,算两个月这样的你自己取舍一下。
(millsec1-millsec2)/(30*24*60*60*1000)
这样就能计算了。

解决方案 »

  1.   

    if(year1>year2)
    {if(month1>month2)  x=(year1-yea2)*12+month1-month2;
    else   x=(year1-yea2)*12-month1+month2;}
    同理,继续。
      

  2.   

    result = (date1.get(Calendar.YEAR) - date2.get(Calendar.YEAR))*12 + 
    (date1.get(Calendar.MONTH)-date2.get(Calendar.MONTH));
      

  3.   

    Tasia(这里是CSDN吗?) 的正解,但是要这样初始化date1:
    Calendar date1 = Calendar.getInstance().setTime(Date.valueOf("2004-7-10"));