Date format Email Notifications Version 1 Templates

Hello,

I know that this topic was already created but the solutions given wasn’t suitable for me.
I want to change the date format for the email notifications like Access requests decision for self and others. IDN says we have to use the spTools to deal with date format however the spTools take a date as argument and the $removeDate is a string so we can’t use it. Consequently, I tried to parse the date from the string and it doesn’t work using the DateTool class even for a simple date “yyy mm dd”

Any solutions?

Hi @Sb_amir,

Can you please share the syntax you are trying to use and what is expected and actual output?

Well i tried this example :

#set($datestr= "Sat, 13 Jan 2024 12:00:00 GMT")
#set($dateobj= $dateTool.toDate("EEE, dd MMM yyyy HH:mm:ss zzz",$datestr))
#set($datefr= $dateTool.format("dd/MM/yyyy", $dateobj))
$datefr

the output should be : 12/01/2024 but it returned blank
i also tried with the $__dateTool but it doesn’t work too

This is a just a test, the datestr should be $removeDate in the access request decision

This is working and tested -

#set($dateObject=$spTools.getClass().forName(“java.util.Date”).newInstance()) 
Current Date:$dateObject.

Below is the output -
Current Date:Tue Jan 23 08:12:50 PST 2024

Mark it as solved, if it helps.

I tried this but test emails are not working after I added this

Hello,
Thank you for your answer.

It works for current date but how can you convert a input date in string format into a dateobject.
The purpose behind this process is to change its format.

@Sb_amir - Use the below to format an input date -

#set($dateObject=$spTools.getClass().forName("java.util.Date").newInstance()) 
#set($formattedDate=$spTools.formatDate($dateObject,"MM/dd/yyyy HH:mm"))
Current Date:$dateObject
Formatted Date:$formattedDate

Output
Current Date:Wed Jan 24 01:35:56 PST 2024
Formatted Date:01/24/2024 01:35

The method I have used here is -

  * @param date Date to format
  * @param formatString Format String (i.e. MM/dd/yyyy HH:mm)
  * @return Formatted date string or empty string if date is null.
  * If the formatString is invalid, the formatted date will default
  * the short style date and time expected by the current locale
  */
public String formatDate(Object date, String formatString);

Mark it as solved, if it helps.

Thank you!

@officialamitguptaa
Maybe i didn’t explain well my need.

I have a date : String date = “01/01/2024”
To perform a format change we have to convert it into a Date type. However, i couldn’t instanciate a Date object from a string date (input) and the parse doesn’t seem to work either.

The code you gave me works to get and format the current date but it doesn’t answer my problem.

Thank you a lot for your time and your answer

dateTool is only available for version 2 templates

v1 can only use $spTools:
https://documentation.sailpoint.com/identityiq/help/systemconfig/sptools_function_library.html

Im struggling with the same issue.

Maybe there is a way to get the original removeDate object

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.