Am having string posting date like :
2011-03-27T09:39:01.607
and There is current date .
I want to get difference between these tw
Convert both dates into calender and make time 0(
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
).
Then use this fun :
public final static long SECOND_MILLIS = 1000;
public final static long MINUTE_MILLIS = SECOND_MILLIS*60;
public final static long HOUR_MILLIS = MINUTE_MILLIS*60;
public final static long DAY_MILLIS = HOUR_MILLIS*24;
public static int daysDiff( Date earlierDate, Date laterDate )
{
if( earlierDate == null || laterDate == null ) return 0;
return (int)((laterDate.getTime()/DAY_MILLIS) - (earlierDate.getTime()/DAY_MILLIS));
}