public static int calcDiff(Calendar c1,long nowMs,int id){
  int presumedDiff;
  int step=1;
switch (id) {
case Calendar.YEAR:
    presumedDiff=(int)((nowMs - c1.getTimeInMillis()) / (Util.MILLIS_IN_YEAR - Util.MILLIS_IN_DAY * 3));
  break;
case Calendar.MONTH:
presumedDiff=(int)((nowMs - c1.getTimeInMillis()) / (Util.MILLIS_IN_MONTH - Util.MILLIS_IN_DAY * 3));
break;
case Calendar.WEEK_OF_MONTH:
case Calendar.WEEK_OF_YEAR:
presumedDiff=(int)((nowMs - c1.getTimeInMillis()) / (Util.MILLIS_IN_DAY * 7 - Util.MILLIS_IN_HOUR * 2));
step=7;
id=Calendar.DATE;
break;
case Calendar.DATE:
presumedDiff=(int)((nowMs - c1.getTimeInMillis()) / (Util.MILLIS_IN_HOUR * 23 - Util.MILLIS_IN_MINUTE * 30));
break;
case Calendar.HOUR:
case Calendar.HOUR_OF_DAY:
return (int)((nowMs - c1.getTimeInMillis()) / Util.MILLIS_IN_HOUR);
case Calendar.MINUTE:
return (int)((nowMs - c1.getTimeInMillis()) / Util.MILLIS_IN_MINUTE);
default :
throw new IllegalStateException("What... is " + id + "?");
}
return calcDiff2(c1,nowMs,presumedDiff,id,step);
}

public static int calcDiff ( Calendar c1 , long nowMs , int id ) { int presumedDiff ; int step = 1 ; switch ( id ) { case Calendar . YEAR : presumedDiff = ( int ) ( ( nowMs - c1 . getTimeInMillis ( ) ) / ( Util . MILLIS_IN_YEAR - Util . MILLIS_IN_DAY * 3 ) ) ; break ; case Calendar . MONTH : presumedDiff = ( int ) ( ( nowMs - c1 . getTimeInMillis ( ) ) / ( Util . MILLIS_IN_MONTH - Util . MILLIS_IN_DAY * 3 ) ) ; break ; case Calendar . WEEK_OF_MONTH : case Calendar . WEEK_OF_YEAR : presumedDiff = ( int ) ( ( nowMs - c1 . getTimeInMillis ( ) ) / ( Util . MILLIS_IN_DAY * 7 - Util . MILLIS_IN_HOUR * 2 ) ) ; step = 7 ; id = Calendar . DATE ; break ; case Calendar . DATE : presumedDiff = ( int ) ( ( nowMs - c1 . getTimeInMillis ( ) ) / ( Util . MILLIS_IN_HOUR * 23 - Util . MILLIS_IN_MINUTE * 30 ) ) ; break ; case Calendar . HOUR : case Calendar . HOUR_OF_DAY : return ( int ) ( ( nowMs - c1 . getTimeInMillis ( ) ) / Util . MILLIS_IN_HOUR ) ; case Calendar . MINUTE : return ( int ) ( ( nowMs - c1 . getTimeInMillis ( ) ) / Util . MILLIS_IN_MINUTE ) ; default : throw new IllegalStateException ( "What... is " + id + "?" ) ; } return calcDiff2 ( c1 , nowMs , presumedDiff , id , step ) ; }
calculates difference in full value units . ( ie if c1 is august 1st , 2011 and c2 is july 31st , 2012 , the difference in years is 0 , months is 11 , days is 364 , etc . , but if c2 is august 1st , 2012 , then the diff is 1 year , or 12 months , or 365 days )
