Hi,
I am interested in formatting a Java Calendar/Date in my Velocity template. I see that VelocityTools provides a DateTool, so I'm wondering:
Or is there another preferred method for formatting Java Calendar/Date objects in the templates?
Thanks!
Lucas
Community moderators have prevented the ability to post new answers.
Hi Lucas,
Although JIRA injects custom date formatter to velocity context:
// locale is default JIRA locale final OutlookDate formatter = new OutlookDate(locale); templateParams.put("dateformatter", formatter);
that can be used in vm like:
$dateformatter.formatDMYHMS($someDate) $dateFormatter.format($someDate)
Full OutlookDate javadoc: https://docs.atlassian.com/jira/latest/com/atlassian/jira/web/util/OutlookDate.html
Thanks Volodymyr. In the end, I used the https://docs.atlassian.com/jira/latest/com/atlassian/jira/datetime/DateTimeFormatter.html instead since the OutlookDate is deprecated. Cheers, Lucas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lucas, Does JIRA inject DateTimeFormatter into the velocity context? If yes, please share the name under which it's injected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Volodomyr, I do not know if it is injected in the Velocity context. I just added it the context in my servlets prior to issuing the response. Lucas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lucas, thank you for sharing!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.