Created on 09-05-2022 03:07 AM - edited 09-05-2022 03:39 AM
Hi Everyone,
I have a use case, where i need to generate timestamp in Epoch UTC format till seconds 1662371646, and perform Substract operation for generate one minute ago time in same format.
below is my Jolt Spec :
[
{
"operation": "default",
"spec": {
"currenttime": "${now():toNumber()}"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"timeOneMinu": "=Subtract(@(1,currenttime),60)"
}
}
]
Output :
{
"currenttime": "1662372281",
"timeOneMinu": "1662372221"
}
Please suggest, How we can do this.
Created 09-05-2022 05:37 AM
Doesn't your JOLT spec solve your own problem?
Cheers,
André
Created on 09-05-2022 05:41 AM - edited 09-05-2022 05:53 AM
@araujo
No, I'm getting the same current time in "timeOneMinu", Subtraction is not performing.
Created 09-05-2022 03:09 PM
What about this:
[
{
"operation": "default",
"spec": {
"currenttime": "${now():toNumber()}",
"timeOneMinu": "${now():toNumber():minus(60)}"
}
}
]
Created on 09-05-2022 03:48 PM - edited 09-05-2022 03:49 PM
Is seems that "subtract" only works for integers and your value is a long. The longSubtract function only works if longs are passed as parameters and I don't know if there's a way to specify a long literal in Jolt (I tried 60L but that doesn't work).
The following does a little bit more work but also achieves what you want:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"currenttime": "=toLong(${now():toNumber()})",
"minute": "=toLong(60)"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"timeOneMinu": "=longSubtract(@(1,currenttime), @(1,minute))"
}
},
{
"operation": "remove",
"spec": {
"minute": ""
}
}
]
Output:
{
"currenttime": 1662417935173,
"timeOneMinu": 1662417935113
}
Cheers,
André