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