Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wicket - strange behavior with parameterized StringResourceModel

This is my resource key:

Expired {0} days ago

This is the definition of the StringResourceModel:

new StringResourceModel("store.expired.tooltip", null, Days.daysBetween(expirationDate, refDate));

Expected result would be something like Expired 20 days ago but the actual result is Expired P20D ago.

Any idea what is causing this? I think I do everything right but not sure.

like image 912
Stijn Geukens Avatar asked Feb 19 '23 19:02

Stijn Geukens


1 Answers

This is actually an error in your usage of joda-time. See the javadoc for joda Days.

Days.daysBetween(expirationDate, refDate) returns a joda Days object, whose toString() method returns ISO8601 duration format string, which is what you're seeing.

Using Days.daysBetween(expirationDate, refDate).getDays() instead will make it an integer, which should format correctly.

like image 71
Don Roby Avatar answered Mar 15 '23 13:03

Don Roby