ocpsoft / prettytime

Social Style Date and Time Formatting for Java
http://ocpsoft.org/prettytime/
Apache License 2.0
1.29k stars 253 forks source link

Make PrettyTime immutable #211

Open gastaldi opened 3 years ago

gastaldi commented 3 years ago

In many cases, PrettyTime can be initialized only once and reused during the application's lifetime. However methods like setLocale and setReference may impact on this approach.

Therefore it would be nice if the PrettyTime object were immutable and methods that change the object's state were deprecated in favor of using it through a constructor

gastaldi commented 3 years ago

Another solution is to return a different object when these methods are called, which I think it makes more sense

lincolnthree commented 3 years ago

@gastaldi Hey! Thanks so much for the idea. I like it. Want to put together a PR? I still have a few things to merge in from the Java 8 update, but this would be a cool improvement. I think it would likely need to bump the major version though.

lincolnthree commented 3 years ago

I wouldn't mind cleaning up some of the APIs at the same time, too.