Formatting Date and Time values
Last updated
Was this helpful?
Last updated
Was this helpful?
Jira Email This Issue gives you full control in formatting date and time values in your email templates by providing a component called $!jetiFieldFormatter
that you can use in the email templates.
Read more about the methods of this component in the section.
Do the following to format date and time values:
Create a formatter object.
Format the date or date-time values using the created formatter.
Create a Jira formatter in your template:
<date time style name>
can be any of the following:
Empty: If called without a parameter, getJiraDateTimeFormatter()
returns the default Jira date time formatter.
The name of a predefined style in DateTimeStyle
. E.g. $!jetiFieldFormatter.getJiraDateTimeFormatter("COMPLETE")
returns a Jira formatter for the COMPLETE
style. Read more about DateTimeStyle
.
There are multiple ways to create a Java date formatter.
Creating a Java formatter with style
<date format style number>
can be any of the following:
Empty: If called without parameters getJavaDateFormat()
returns the default Java formatter.
The value of a date format style constant in DateFormat
. E.g. $!jetiFieldFormatter.getJavaDateFormat(1)
returns a DateFormat
instance for the DateFormat.LONG
style.
(Optional) <locale string>
: The Java string representation of a locale. Always use language and country, like "en_GB
" or "de_DE
" or "hu_HU
". If not provided, the user's default locale will be used.
Creating a Java formatter with pattern
<date time pattern>
can be a valid pattern according to Java SimpleDateFormat
specification. E.g. a pattern of dd/MM/yyyy HH:mm
returns a formatter that formats the timestamp of May 31, 2022 1:35pm.
Once you have a formatter, the date or date-time field values can be formatted in the following way:
<date time value>
may be either:
An issue attribute, like $!issue.created
or $!issue.updated
An issue custom field: $!issue.getCustomFieldValue("customfield_12345")
, where "customfield_12345
" is the custom field key of a Date Picker or DateTime
Picker field. Calling the formatter with a non-date value will render an empty string.
To render the date or date-Time values in a time zone both the Jira DateFormatter and Java DateFormat can be used. There is a list of Timezone IDs are available for Java.
Example for rendering the issue's due date in Alaska time using the Java DateFormat API:
Example for rendering the issue's due date in Alaska time using the Jira DateFormatter API:
We support using the time zone set in the current userβs profile. For example to render the issue's last update date-time with the current user's time using the TemplateSupport's currentUsersTimeZoneId
.