When you see a post it always shows time posted in hours ago or days ago. If you are also kooing to implement the same functionality using Android than use the below method that convert date or time in " hours or days".
//firstly find out difference between current time and other time
long diff = currentdate.getTime() - temp_date.getTime();
//firstly find out difference between current time and other time
long diff = currentdate.getTime() - temp_date.getTime();