Created on 08-30-2018 10:57 AM - edited 08-18-2019 03:04 AM
Hi all,
I nifi I have an attribute with filename from which I extracted date with substring (only yyyyMMdd portion).
After that I want to calculate year week number for date 2018/08/19 (formated from string portion 20180819024112) which is week number 33.
If I use format without specified timezone ('GMT'), I get week number 34, but with specified timezone I get correct week number 33. What is the difference? Why do I get wrong week number without timezone. GMT is only +2 hours from 19th of August Midnight.
Thanks,
Tom
Created 08-31-2018 07:33 AM
Could it be that in GMT weeks start on Monday whereas weeks in your implicit timezone start on Sunday? Which timezone is your system set to?
Another thing to check could be what date you get when you use:
(...):format('yyyy-MM-dd HH:mm:ss', 'GMT')
Is it what you're expecting?
Created 08-31-2018 09:05 AM
Timezone on my system is UTC+1 and first day of the week is Monday (also specified on my system).
With (...):format('yyyy-MM-dd HH:mm:ss', 'GMT') I get 2018-08-18 22:00:00, but without 'GMT' I get 2018-08-19 00:00:00.
Created 09-03-2018 09:12 PM
Hello @Tomislav Novosel!
I tried to make the same test as you, but unfortunately, I got 34, even after removing the GMT.
Here's my template.
testing-tmz.xml
Also here's the step that I took:
su - nifi mkdir -p /home/nifi/play_ts/cd /home/nifi/play_ts/touch 20180819024112
BTW, my timezone it's UTC. And my formula it's a little bit different from yours cause I'm skipping the getDelimitedFields.
${filename:substring(0,8):toDate("yyyyMMdd"):format("w","GMT")}