Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Date function in REST connection (CreateAccountJSON)

ShyamSrisailam
Regular Contributor
Regular Contributor

Hi All,

Do you have the correct date function for below use case. I need to use this condition in CreateAccJSON - REST connection

If create date is within 2 days of the current date it should print "false" or else it should print "true". I tried adding below condition but not working. Let me know if anyone has used the similar date functions.

 

\"license\":\"${((user.createDate)>=(Calendar.getInstance().getTime().minusDays(2)))?'false':'true'}\"

\"license\":\"${((user.createDate)>=(new SimpleDateformat('YYYY-MM-dd HH:mm:ss').format(Calendar.getInstance().add(Calendar.DAY_OF_MONTH,-2).getTime()))?'false':'true'}\"

\"license\":\"${ABS(DATEDIFF(CURDATE(), user.createdate)) <= 2}\"

\"license\": \"${DATEDIFF(NOW(), createdate) <= 2}\"

 

Regards
SrisailamShyamSundarGoud
7 REPLIES 7

AmitM
Valued Contributor
Valued Contributor

Hi @ShyamSrisailam , Not exact use case yet but I am using something like this in provisioning json.

{\"type\": \"AfterDateTime\",\"endDateTime\": \"${(Calendar.getInstance().getTime()+ 1).format(\"yyyy-MM-dd'T'HH:mm:ss\")}Z\"}

Hope you can drive your use case from it.

Thanks,

Amit

If this answers your query, Please ACCEPT SOLUTION and give KUDOS.

rushikeshvartak
All-Star
All-Star

\"license\": \"${((Calendar.getInstance().getTimeInMillis() - user.createDate.getTime()) <= (2 * 24 * 60 * 60 * 1000)) ? 'false' : 'true'}\"


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

ShyamSrisailam
Regular Contributor
Regular Contributor

Thanks for the response.

@AmitM - I need a syntax to minus 2 days from the current date and compare it with create date.

@rushikeshvartak - I have tried the syntax you provided but it's didn't work.

 

Regards
SrisailamShyamSundarGoud

"license": "${(java.time.LocalDate.parse(user.createDate).isAfter(java.time.LocalDate.now().minusDays(2))) ? 'true' : 'false'}"


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

"license": "${java.util.Calendar.getInstance().getTime().getTime() - java.util.Calendar.getInstance().getTimeInMillis() >= java.util.Calendar.DAY_OF_MONTH * 2) ? 'true' : 'false'}"


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

"license": "${(java.util.Calendar.getInstance().toInstant().minus(java.time.temporal.ChronoUnit.DAYS, 2).isBefore(java.time.Instant.parse(user.createDate))) ? 'true' : 'false'}"


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

ShyamSrisailam
Regular Contributor
Regular Contributor

Hi @rushikeshvartak ,

I tried all the conditions you have provided but it's not working. 

Logs says "\license\" was of unexpected type" and I think that target application is expecting result in Boolean value since the "License" attribute in target is Boolean Date Type.

 

Regards
SrisailamShyamSundarGoud