I am using the joda-time grails plugin in my grails app to deal with durations. The plugin saves durations decoded in milliseconds in the database, prefixes it with “PT” and suffixes with “s”. Example 1 minute = PT3600S
Now I want to order this row. As it is a varchar ordering gets complicated or better not as I want it to be ordered 🙁
result
PT12551S
PT21142S
PT23240S
PT4672S
PT4792S
PT4877S
expected (if it type is int…)
PT4672S
PT4792S
PT4877S
PT12551S
PT21142S
PT23240S
Any idea how to work around this? Can I change the format of the data that is stored in db? Can I change the ordering to regard the length of the entry?
I figured out the best way to do it is not to use this kind of shortcut for now. I am now saving the durations as integers. That way it is easy to order and add.