I want to convert:
2010-03-15T16:34:46Z
into something like "5 hours ago"
How can I do this in Java?
I want to convert:
2010-03-15T16:34:46Z
into something like "5 hours ago"
How can I do this in Java?
I know a plugin in Jquery for this : http://plugins.jquery.com/project/CuteTime
For Java i assume you will need to use your brain :) ( You can translate it to Java )
JodaTime supports parsing from a user-defined format. See DateTimeFormatterBuilder and DateTimeBuilder.parseDateTime().
Once you have a DateTime, you can create a Duration or Period from that and the current time, and use another formatter to pretty-print. [See the PeriodFormatter example referenced by BalusC in comments above.]
Calendar calendar = new GregorianCalendar(2010,Calendar.March,15, 16,34,46);
calendar.add(Calendar.HOUR,-5);