Stijn Geukens
Stijn Geukens

Reputation: 15628

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.

Upvotes: 4

Views: 554

Answers (1)

Don Roby
Don Roby

Reputation: 41145

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.

Upvotes: 8

Related Questions