Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

want to convert date format from mm-dd-yyyy to mm/dd/yyyy

Rajesh_IAM
Regular Contributor
Regular Contributor

Hi All,

Facing issue while converting  date format from mm-dd-yyyy to mm/dd/yyyy

Its a REST based application.

We are getting user's start date from feed in the format of mm-dd-yyyy to saviynt. As a part of requirement, I need to convert date format to "mm/dd/yyyy" and push this value to target application. I tried with replace() in JSON as below , still not working.

\"hire_date\": \"${String str=user.customproperty10;str=str.replace('-','\\');return str;}\"

Can anyone please help me on this date conversion issue.

5 REPLIES 5

Darshanjain
Saviynt Employee
Saviynt Employee

Can you please try with the simple one:

\"hire_date\": \"${user.customproperty10.replace('-','//')}\". 

Also try with ( //// ) instead of 2 if in case it doesn't work and check out

Rajesh_IAM
Regular Contributor
Regular Contributor

@Darshanjain  Thank you for response.
I tried with both options( //  as well as ////), but still its not working and throwing error as "[{"errors":[{"type":"Please enter a valid date in this mm/dd/yyyy format."}]}}"

adriencosson
Regular Contributor III
Regular Contributor III

Hi @Rajesh_IAM,

You may try the SimpleDateFormat (hoping this is available in REST connector), using the below code :

${new SimpleDateFormat("mm/dd/yyyy").parse(user.customproperty10)} 

Otherwise, you may need to import it before, using : 

import java.text.SimpleDateFormat;

Also, please confirm the start date is retrieved in a customproperty, to ensure it is inserted in the identity as String.

If it is stored in Start Date attribute, you would use the below script (at it considered a Date as input) :

user?.startdate.format('mm/dd/yyyy')

Hope this helps !

Regards,
Adrien COSSON

Darshanjain
Saviynt Employee
Saviynt Employee

Hi @Rajesh_IAM 

This is directly working in other environments , have you tried this and did you see a error ,if not send me a error of logs how it is getting converted.

\"hire_date\": \"${user.customproperty10.replace('-','/')}\". 

Rajesh_IAM
Regular Contributor
Regular Contributor

@Darshanjain  Its working as expected. Thank you for help 🙂