Simple Human readable time in Java

20 Jun

Want to show time like shown in Twitter or Orkut about an event. Want to identify the time of event in weeks, days or hours as compared to the given time. If yes then Pretty Time provides solution for this. Being open source it will not have any additional cost and yes the learning curve is also very small.

PrettyTime is an OpenSource time formatting library. Completely customizable, PrettyTime creates human readable, relative timestamps like those seen on Digg, Twitter, and Facebook. It’s simple, get started “right now!”

Downlaod Pretty Time API from

Using it is very simple.

The following code will help you understand how to use it.

import java.util.Date;
import com.ocpsoft.pretty.time.PrettyTime;

public class BasicJavaApp
	public static void main(String[] args)
		PrettyTime p = new PrettyTime();
		System.out.println(p.format(new Date()));

Will give you the output “right now”

Leave a comment

Posted by on June 20, 2009 in Java


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: