<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Date with now() in a specific format in a specific timezone in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389025#M246865</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110657"&gt;@ranie&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I see a couple issues with your NiFi Expression Language (NEL) statement:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I see some formatting issues in your java simple formatter string: &lt;SPAN&gt;'yyyy-MM-dd\'T\'00:00:00\'Z\'.&amp;nbsp; &amp;nbsp;Your single and double quotes are not balanced.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;You are using the function "format ()" to change the timezone, but you could also use the "formatInstant()" function.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;You are missing the "toNumber()" function to convert the date string to a number before trying to apply a mathematically computation to it.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#now" target="_blank" rel="noopener"&gt;Now()&lt;/A&gt; function will return the date current system time as the NiFi service sees it.&lt;BR /&gt;example: my NiFi server uses UTC timezone:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1718113511430.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40942i2C55465AF87B6FDC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1718113511430.png" alt="MattWho_0-1718113511430.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#tonumber" target="_blank" rel="noopener"&gt;toNumber()&lt;/A&gt; function will provide the current date and time as a number of milliseconds since midnight Jan 1st, 1970 GMT.&amp;nbsp; &amp;nbsp;This number will always be a GMT value.&lt;BR /&gt;&lt;BR /&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#formatInstant" target="_blank" rel="noopener"&gt;formatInstant()&lt;/A&gt; function will allow you to take a GMT time or a Java formatted date string and reformat it for a different timezone.&lt;BR /&gt;&lt;BR /&gt;Taking above feedback into consideration, the following NEL statement should work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():toNumber():minus(86400000):formatInstant("yyyy-MM-dd'T'HH:mm:ss 'Z'", "CET")}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pay close attention to your use of single and double quotes.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please help our community thrive. If you found&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;any&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on&amp;nbsp;&lt;STRONG&gt;one or more&lt;/STRONG&gt;&amp;nbsp;of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2024 13:58:47 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2024-06-11T13:58:47Z</dc:date>
    <item>
      <title>Date with now() in a specific format in a specific timezone</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389005#M246857</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;What I did was :&amp;nbsp;&lt;BR /&gt;${now():minus(86400000):format('yyyy-MM-dd\'T\'00:00:00\'Z\'' , 'CET')}&amp;nbsp;&lt;BR /&gt;but this still gave me the time at midnight in UTC and not CET.&lt;BR /&gt;&lt;BR /&gt;What I want basically is if today is 2024-06-11 I want to get :&amp;nbsp;&lt;SPAN&gt;2024-06-10T22:00:00Z&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;also, there is this issue with the CEST , If I specify CET is CEST not considered ?&amp;nbsp;&lt;BR /&gt;I just don't want to have to change my processor every 6 months a year and have something that works no matter what&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 07:48:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389005#M246857</guid>
      <dc:creator>ranie</dc:creator>
      <dc:date>2024-06-11T07:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date with now() in a specific format in a specific timezone</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389016#M246861</link>
      <description>&lt;P&gt;Ideally, it should return the current date minus 24 hours and convert it to a specific time zone. Please check your server time.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="saquibsk_3-1718099917158.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40937i84F4C212654F4660/image-size/medium?v=v2&amp;amp;px=400" role="button" title="saquibsk_3-1718099917158.png" alt="saquibsk_3-1718099917158.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CET:&amp;nbsp;&lt;/STRONG&gt;${now():toNumber():minus(86400000):format('yyyy-MM-dd HH:mm:ss', 'CET')}&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GMT:&amp;nbsp;&lt;/STRONG&gt;${now():toNumber():minus(86400000):format('yyyy-MM-dd HH:mm:ss', 'GMT')}&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Midnight CET:&amp;nbsp;&lt;/STRONG&gt;${now():toNumber():minus(86400000):format('yyyy-MM-dd', 'CET'):append(' 00:00:00')}&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 09:59:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389016#M246861</guid>
      <dc:creator>saquibsk</dc:creator>
      <dc:date>2024-06-11T09:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date with now() in a specific format in a specific timezone</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389025#M246865</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110657"&gt;@ranie&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I see a couple issues with your NiFi Expression Language (NEL) statement:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I see some formatting issues in your java simple formatter string: &lt;SPAN&gt;'yyyy-MM-dd\'T\'00:00:00\'Z\'.&amp;nbsp; &amp;nbsp;Your single and double quotes are not balanced.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;You are using the function "format ()" to change the timezone, but you could also use the "formatInstant()" function.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;You are missing the "toNumber()" function to convert the date string to a number before trying to apply a mathematically computation to it.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#now" target="_blank" rel="noopener"&gt;Now()&lt;/A&gt; function will return the date current system time as the NiFi service sees it.&lt;BR /&gt;example: my NiFi server uses UTC timezone:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1718113511430.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40942i2C55465AF87B6FDC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1718113511430.png" alt="MattWho_0-1718113511430.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#tonumber" target="_blank" rel="noopener"&gt;toNumber()&lt;/A&gt; function will provide the current date and time as a number of milliseconds since midnight Jan 1st, 1970 GMT.&amp;nbsp; &amp;nbsp;This number will always be a GMT value.&lt;BR /&gt;&lt;BR /&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#formatInstant" target="_blank" rel="noopener"&gt;formatInstant()&lt;/A&gt; function will allow you to take a GMT time or a Java formatted date string and reformat it for a different timezone.&lt;BR /&gt;&lt;BR /&gt;Taking above feedback into consideration, the following NEL statement should work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():toNumber():minus(86400000):formatInstant("yyyy-MM-dd'T'HH:mm:ss 'Z'", "CET")}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pay close attention to your use of single and double quotes.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please help our community thrive. If you found&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;any&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on&amp;nbsp;&lt;STRONG&gt;one or more&lt;/STRONG&gt;&amp;nbsp;of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 13:58:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Date-with-now-in-a-specific-format-in-a-specific-timezone/m-p/389025#M246865</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2024-06-11T13:58:47Z</dc:date>
    </item>
  </channel>
</rss>

