Skip to content
Advertisement

Tag: datediff

How to calculate “time ago” in Java?

In Ruby on Rails, there is a feature that allows you to take any Date and print out how “long ago” it was. For example: Is there an easy way to do this in Java? Answer Take a look at the PrettyTime library. It’s quite simple to use: You can also pass in a locale for internationalized messages: As noted

Advertisement