Get time difference in Java

UPDATED: 29 November 2011
When we are developing some application time is most required attribute. We have to capture when user did something and we want to show that last activity done "x seconds ago...." , "x minutes ago....","x months ago...."








Requirement : Date must be in  Nov 29, 2011 6:54:56 PM in this format. 

How to get date in this format?
        Date d = new Date();
        String current_date = d.toLocaleString();

O/P
        Nov 29, 2011 6:54:56 PM

javaQuery.core.TimeDifference

public class timed {
    public static void main(String[] args) {
        String test_date = "Nov 29, 2011 6:54:56 PM";
        TimeDifference td = new TimeDifference();
        System.out.println(td.GetDifference(test_date));
    }
}

O/P 
      1 hour ago...

0 comments :