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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With