Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

fieldsJEMH JEMH velocity context, relating to emails (comment header specifically) has $sentDate (if present, reverts to now() if not) as well as $receivedDate.  Presentation of these dates can be altered through helper classes in the velocity context.

...

JEMH can build date objects too, to enable values to be generated for arbitrary dates, ege.g.:

Date Time
Code Block
#set($longVal = $currentMillis.longValue() + 86400000 )
$dateFormatter.format($jemhDateUtils.createDate($longVal))

...

When using the above, it operates in the context of the 'current' user, typically the sender of a mail (for incoming custom field defaults). You can default the locale of the date by using withDefaultLocale()from https://docs.atlassian.com/DAC/javadoc/jira/reference/com/atlassian/jira/datetime/DateTimeFormatter.html:

...

  • ZonedDateTime - we are using ZonedDateTime which allows us to retain the timezone time zone aspect along with the date + time. This is vital aspect in case you’d wish to convert this to another timezone time zone (which is what is being done in the above example)

  • Formatter - to format the date in a certain pattern (i.e. 12/02/2020 - 08:29), we have provided the getFormatter(pattern) method which is responsible for returning a DateTimeFormatter. The same can be used to format the ZonedDateTime to any other preferred format

...

This set of methods doesn’t depend on any Jira user in the authentication context, ege.g., you want to do date/time manipulation for a custom field default

...