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

Fixed that setLocale method can't change format language #173

Closed JayDi85 closed 5 years ago

JayDi85 commented 5 years ago

It's a bug with mutable cached units. If you call setLocale to change language then cached units is not updated and will return old values (e.g. language don't switches).

Example:

PrettyTime t = new PrettyTime(Locale.ENGLISH);
t.setLocale(Locale.FRENCH);        
System.out.println(t.format(new Date())); // error: returns english, but must french
lincolnthree commented 5 years ago

Looks good. Thanks Jay. Sorry for the delay!