views:

68

answers:

3

I want to convert:

2010-03-15T16:34:46Z

into something like "5 hours ago"

How can I do this in Java?

A: 

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 )

racar
+1  A: 

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.]

Andy Thomas-Cramer
A: 
     Calendar calendar = new GregorianCalendar(2010,Calendar.March,15, 16,34,46);
     calendar.add(Calendar.HOUR,-5);
Chuckie
You misinterpreted the question.
Matthew Flaschen