Created 06-11-2024 12:48 AM
In an UpdateAttribute processor I am trying to get the date of yesterday, at midnight in the CET timezone then have it transformed to a specific format in UTC.
What I did was :
${now():minus(86400000):format('yyyy-MM-dd\'T\'00:00:00\'Z\'' , 'CET')}
but this still gave me the time at midnight in UTC and not CET.
What I want basically is if today is 2024-06-11 I want to get : 2024-06-10T22:00:00Z
also, there is this issue with the CEST , If I specify CET is CEST not considered ?
I just don't want to have to change my processor every 6 months a year and have something that works no matter what
Created 06-11-2024 02:59 AM
Ideally, it should return the current date minus 24 hours and convert it to a specific time zone. Please check your server time.
CET: ${now():toNumber():minus(86400000):format('yyyy-MM-dd HH:mm:ss', 'CET')}
GMT: ${now():toNumber():minus(86400000):format('yyyy-MM-dd HH:mm:ss', 'GMT')}
Midnight CET: ${now():toNumber():minus(86400000):format('yyyy-MM-dd', 'CET'):append(' 00:00:00')}
Thanks
Created on 06-11-2024 06:55 AM - edited 06-11-2024 06:58 AM
@ranie
I see a couple issues with your NiFi Expression Language (NEL) statement:
The Now() function will return the date current system time as the NiFi service sees it.
example: my NiFi server uses UTC timezone:
The toNumber() function will provide the current date and time as a number of milliseconds since midnight Jan 1st, 1970 GMT. This number will always be a GMT value.
The formatInstant() function will allow you to take a GMT time or a Java formatted date string and reformat it for a different timezone.
Taking above feedback into consideration, the following NEL statement should work for you.
${now():toNumber():minus(86400000):formatInstant("yyyy-MM-dd'T'HH:mm:ss 'Z'", "CET")}
Pay close attention to your use of single and double quotes.
Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt