cancel
Showing results for 
Search instead for 
Did you mean: 

Converting string into date and applying transformation failing

vaidyarm
Contributor

I am passing a timestamp as a variable through pipeline parameter as ‘p_querystring_modifieddateafter’.

while applying logic as below in mapper and in REST GET snap parameters, I am getting the failure :

Logic in Mapper :
_p_querystring_modifieddateafter.minusDays(1).toLocaleDateString()+“T00:00:00.000”

tried with below logic also, still failing,

LocalDateTime.parse(_p_querystring_modifieddateafter).minusDays(1).toLocaleDateString()+“T00:00:00.000”

let me know if i am making any mistake…

2 1

6 REPLIES 6

tstack
Former Employee

Can you give an example of one of these timestamps? It looks like LocalDateTime.parse() is not parsing it correctly and returning a NaN. Also, is there are reason you’re using LocalDateTime.parse() instead of Date.parse()? Note that LocalDateTime objects do not have the date math methods like minusDays().

vaidyarm
Contributor

Ex :
2019-08-09T06:51:07.000

this need to be converted like : 2019-08-08T00:00:00.000

This expression:
Date.parse(“2019-08-09T06:51:07.000”).minusDays(1).toLocaleDateString()+“T00:00:00.000”

results in: 2019-08-08T00:00:00.000

Note the only change in the expression from your original one is the use of Date.parse() instead of LocalDateTime.parse()

vaidyarm
Contributor

for this logic :
Date.parse(“2019-08-09T06:51:07.000”).minusDays(1).toLocaleDateString()+“T00:00:00.000”

error :
Could not compile expression: Date.parse(“2019-08-09T06:51:0 … (Reason: Invalid token: ‘“’ for expression: Date.parse(“2019-08-09T06:51:0 …; Resolution: Please check expression syntax)

attached are screenshots. 4 3