02/26/2023 11:28 PM
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.
Solved! Go to Solution.
02/27/2023 02:22 AM
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
02/27/2023 06:29 AM
@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."}]}}"
02/27/2023 01:39 PM
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 !
02/28/2023 04:27 AM
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('-','/')}\".
03/01/2023 05:32 AM
@Darshanjain Its working as expected. Thank you for help 🙂