Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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.

Lower down there are several date operators that are hyperlinked to API Documentation so you know what you can do with them:

For example:

1a) $dateFormatter.format($sentDate)
1b) $dateFormatter.forLoggedInUser().withStyle($dateTimeStyle.RSS_RFC822_DATE_TIME).format($sentDate)
1c) $dateFormatter.forLoggedInUser().withStyle($dateTimeStyle.DATE_TIME_PICKER).format($sentDate)
1d) $dateFormatter.forLoggedInUser().withStyle($dateTimeStyle.RELATIVE).format($sentDate)
2) $outlookdate.formatDMY($sentDate) $outlookdate.formatTime($sentDate)
3) $dateformatter.getNow() / $dateformatter.formatIso8601($dateformatter.getNow()) 
4) $dateTimes.formatRSS($sentDate)

Generates:

1a) 16/Jan/15 10:47 AM
1b) Fri, 16 Jan 2015 10:47:48 +0000
1c) 16/Jan/15 10:47 AM
1d) Today 10:47 AM
2) 16/Jan/15 10:47 AM
3) Fri Jan 16 10:47:48 GMT 2015 / 2015-01-16T10-47
4) Fri, 16 Jan 2015 10:47:48 +0000

Velocity Custom Field Dates

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

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

Example Output:

29/Mar/15 3:41 PM

Date Only
#set($longVal = $currentMillis.longValue() + 86400000 )
$dateFormatter.withStyle($dateTimeStyle.DATE).format($jemhDateUtils.createDate($longVal))

Example Output:

29/Mar/15

JEMHDateUtils

SINCE 3.2.6

JEMHDateUtils is another interface written by JEMH to accommodate certain functionality which is not achievable when working with Dates obtained from the email.

#set ($dateFormat = "E, dd MMM yyyy hh:mm:ssZ")
#foreach($headerDate in $message.getHeader("date"))

#set ($ukDate = $jemhDateUtils.stringToDate($dateFormat, "Europe/London", $headerDate))
#set ($localisedDateStr = $jemhDateUtils.localiseDate($ukDate, "America/Los_Angeles"))
#set ($localisedDate = $jemhDateUtils.stringToDate("yyyy-MM-dd'T'HH:mm:ss", "America/Los_Angeles", $localisedDateStr))
#set ($formattedDate = $jemhDateUtils.formatDate("dd/MM/yyyy hh:mm aa", $localisedDate))

Header date: $headerDate ($headerDate.class)
UK Date: $ukDate ($ukDate.class)
Los Angeles Date: $localisedDate ($localisedDate.class)
Formatted Date for Los Angeles: $formattedDate ($formattedDate.class)
#end

Example Output:

Header date: Sun, 19 Jun 2011 17:42:26 +1200 (class java.lang.String)
UK Date: Sun Jun 19 06:42:26 BST 2011 (class java.util.Date)
Los Angeles Date: Sat Jun 18 22:42:26 BST 2011 (class java.util.Date)
Formatted Date for Los Angeles: 18/06/2011 10:42 PM (class java.lang.String)

The above is an indication of the dates returned in addition to the type of class the object is.

  • No labels