Date formatting in velocity template - availability of VelocityTools?

Lucas Layman August 29, 2015

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:

  1. Are VelocityTools included in the Atlas SDK?
  2. If so, How to access the DateTool?

Or is there another preferred method for formatting Java Calendar/Date objects in the templates?

Thanks!

Lucas

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2015

Hi Lucas,

  1. No.

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

Lucas Layman August 31, 2015

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

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2015

Lucas, Does JIRA inject DateTimeFormatter into the velocity context? If yes, please share the name under which it's injected.

Lucas Layman August 31, 2015

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

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2015

Lucas, thank you for sharing!

TAGS
AUG Leaders

Atlassian Community Events