8

Are there any libraries for Java that allow you to interpret dates like "Yesterday", "Next Monday", ...

carrier
  • 32,209
  • 23
  • 76
  • 99
  • 1
    Do you mean the string literals, or just something that makes it easy to walk a date back a day or figure out the date of the first Monday in the future, but not providing the text parsing of a literal "Next Monday?" – Yishai Jul 27 '09 at 15:23

3 Answers3

4

You are looking for Natty. Feel free to fork it and modify its grammar.

Michael Mior
  • 28,107
  • 9
  • 89
  • 113
pathikrit
  • 32,469
  • 37
  • 142
  • 221
  • 1
    Might be worth noting that as of March 2021 (this comment), Natty has not been updated for 4 years. https://github.com/joestelmach/natty – Michael Mior Mar 25 '21 at 17:49
2

Su-time from stanford is your (and my) friend.

YaDa
  • 1,253
  • 1
  • 13
  • 15
1

A library like Joda-Time is probably as close as you're gonna get. It doesn't convert strings, but offers much more functionality than the Java default Date class.

Here is a utility class that provides some of the functions you're looking for, but again without fuzzy string conversion.

Daniel F. Thornton
  • 3,687
  • 2
  • 28
  • 41