AppDynamics Knowledge Base

How do I convert event times to international standard time format?

How do I convert event times to international standard time format?

Question

I want to report the event time in an email template using the international standard time format. How can I do this?

Answer

Use the following Apache Velocity template to convert the time into the format you need.

If using html body:

#set( $String = '' )
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS%Tp ', 
$latestEvent.eventTime)

  

If using text body:

#set( $String = '' )## 
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS%Tp ', 
$latestEvent.eventTime)

Sample output:

2017-02-07T13:14:02PM

Let us say you do not need AM/PM at the end of the date, the format is:

#set( $String = '' )
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS ', 
$latestEvent.eventTime)

Sample output:

2017-02-07T13:23:06

  

Resources: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#dt

  

Currently it is not possible to convert from one timezone to another, for example from PST to UTC.

Comments

How to convert for slack?

Version history
Last update:
‎02-07-2017 10:46 AM
Updated by: