Formatting dates in templates
Summary
Within the Template Velocity context there are a couple of different Date formatting methods that allow you to change the how the dates are shown within the Template.
Current Time
$currentMillisThe current time is expressed in the timezone of your server, eg:
millis = $currentMillis
#set ($value = $dateFormatter.formatDateTime($currentMillis))
formatted $value==
renders as:
millis = 1758553307372
formatted 22/Sep/25 4:01 PMSome example methods
Within the $dateFormatter context there are couple of different methods that will format the dates in different ways.
$dateFormatter.format
This method allows to define a custom pattern to use when formatting the date. For more info about defining a custom pattern see: SimpleDateFormat (Java Platform SE 8 )
$dateFormatter.format(value, pattern) Value - the string date value that should be formatted.
Pattern - this is the pattern that should be used to format the value.
Example method:
$dateFormatter.format($aComment.updated.asText(),"yyyy,MMM,dd HH:mm a")Example output:
2023,Nov,07 09:13 AM$dateFormatter.formatTimeZoneId
This method allows to define a custom pattern to use when formatting the date. For more info about defining a custom pattern see: SimpleDateFormat (Java Platform SE 8 )
$dateFormatter.formatTimeZoneId(value, pattern, timeZoneId) Value - the string date value that should be formatted.
Pattern - this is the pattern that should be used to format the value.
TimeZoneId - this is the time zone that should be used when converting this date, using format of {AREA}/{LOCATION} (e.g. Europe/London). See the following for all available time zones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Example method:
London: $dateFormatter.formatTimeZoneId(1758553307372,"yyyy,MMM,dd HH:mm a Z", "Europe/London")
Los Angeles: $dateFormatter.formatTimeZoneId(1758553307372,"yyyy,MMM,dd HH:mm a Z", "America/Los_Angeles")Example output:
London: 2025,Sept,22 16:01 pm +0100
Los Angeles: 2025,Sept,22 08:01 am -0700$dateFormatter.formatDate
This method formats only the date part of the value and will display in the following pattern dd/MMM/yy.
$dateFormatter.formatDate(value)Value - is the string date value that should be formatted.
Example method:
$dateFormatter.formatDate($aComment.updated.asText())Example Output:
07/Nov/23
$dateFormatter.formatDateTime
This method formats the date and time part of the value and will display using the following pattern dd/MMM/yy hh:mm a
$dateFormatter.formatDateTime(value)Value - the string date value that should be formatted
Example method:
$dateFormatter.formatDateTime($aComment.updated.asText())Example Output:
07/Nov/23 9:13 AM
$dateFormatter.formatDay
This method only formats the day of the week and the time.
$dateFormatter.formatDay(value)Value - the string date value that should be formatted
Example method:
$dateFormatter.formatDay($aComment.updated.asText())Example Output:
Tuesday 9:13 AM
$dateFormatter.formatTime
This method only formats the time of the day using format hh:mm a
$dateFormatter.formatTime(value)Value - the string date value that should be formatted.
Example Method:
$dateFormatter.formatTime($aComment.updated.asText())Example Output:
9:13 AM