2

I'm looking for a complete Date management library in java that would allow me to understand strings like :

  • Tomorrow at noon => 2011-10-20 12:00
  • Today at 4pm => 2011-10-20 16:00

etc...

But it would be perfect if this lib would also be Internationalized. I plan to use it in many languages, and "just" english wouldn't be enough.

I already found http://www.datejs.com/ as a possibility, but it's for Javascript (client)'s side. I'm looking for something in Server side.

Thanks for your help!

Cyril N.
  • 38,875
  • 36
  • 142
  • 243

3 Answers3

1

PrettyTime is what you need

Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
  • OK, could you give an example on how to *parse* such "pretty" values? I believe this is what the question is about... – Paweł Dyda Oct 19 '11 at 18:34
  • In fact I was just looking for a library that could help me archive that. But if you want examples, I found them at http://ocpsoft.com/prettytime/#examples – Cyril N. Oct 20 '11 at 09:06
  • I removed the Accepted because apparently this lib does the opposite : you give a date, it returns the date as textual. What I'm looking for is a lib that would return an object Date from a String. – Cyril N. Oct 20 '11 at 11:37
0

You could easily build that yourself with e.g. Joda Time.

flash
  • 6,730
  • 7
  • 46
  • 70
  • Do you have an example on how to do it? I know Joda Time, but can't see how this could help me achieve the way I want :/ Thanks! – Cyril N. Oct 19 '11 at 14:02
0

An similar question was at PHP's strtotime() in Java and here's a good answer. @dfa did an object that do exactly what I'm looking for, you can find the link here

Community
  • 1
  • 1
Cyril N.
  • 38,875
  • 36
  • 142
  • 243