First of all I'm new to java.time
package.
I'm writing a webapp that need to work with specific times of the day and with several durations of events.
So I wrote my code using LocalTime
and Duration
classes of java.time
package.
When I need to render their value in JSP it is very simple for LocalTime
object (because .toString()
returns a human readable vale), so I can just write ${startTime}
and everything goes in the right way (e.g. it is rendered as 9:00
).
The same approach doesn't work for Duration, because its representation is something like PT20M
(in this case for 20 minutes).
Does it exist an elegant way to perform a human-readable conversion in JSP directly by EL?
Yes, I know I can convert the object in a string in my classes (before JSP), but I'm searching for the suggested approach (that I'm not able to find)... another point is that I not see an official "convert()" (or whatever else) method in Duration object... so I'm thinking I'm using the wrong object to map a duration of time (to add or subtract on LocalTime
s).
Thank you.