What is the best way to format time like modern web-pages (including StackOverflow ;-) do, i.e. using simple relative descriptions like:
I am looking for a library that can handle this in addition to multiple locales. I can supply the phrases ( "X seconds" in English, "X Sekunden" in German etc.).
I think this is what you are looking for :
How to calculate "time ago" in Java?
The lib: PrettyTime
For German:
PrettyTime p = new PrettyTime(new Locale("de"));
System.out.println(p.format(new Date()));
For English:
PrettyTime p = new PrettyTime();
System.out.println(p.format(new Date()));
Apparently available in 25 languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With