4

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.

Community
  • 1
  • 1
Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101

1 Answers1

8

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.

Don Roby
  • 40,677
  • 6
  • 91
  • 113
  • So focused on understanding the StringResourceModel that this never occurred to me; I just assumed it returned an int. Time to call it a day I think :-). Tx! – Stijn Geukens Jul 21 '12 at 14:34