<?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: SCPI: CF: Date camel expression use in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/13771664#M4838322</link>
    <description>&lt;P&gt;Hi Morten&lt;/P&gt;&lt;P&gt;....impressive that there is no reference on this anywhere...I had the same issue and solution was found only in your reply (thumbs up!!!)&lt;/P&gt;&lt;P&gt;Other References&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://camel.apache.org/components/4.4.x/languages/simple-language.html" target="_self"&gt;Camel Components / Language / Simple (for v4.4)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://camel.apache.org/components/4.4.x/languages/file-language.html#_samples" target="_self"&gt;Date usage samples&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and even in SAP Help (&lt;A href="https://help.sap.com/docs/cloud-integration/sap-cloud-integration/camel-data-model-in-nutshell" target="_self"&gt;camel-data-model-in-nutshell&lt;/A&gt;&amp;nbsp;) the documentation is on high level.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 09:57:07 GMT</pubDate>
    <dc:creator>mmastora</dc:creator>
    <dc:date>2024-07-25T09:57:07Z</dc:date>
    <item>
      <title>SCPI: CF: Date camel expression use</title>
      <link>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaq-p/12494913</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;
  &lt;P&gt; I'm trying to use camel Date expression to calculate dates:&lt;/P&gt;
  &lt;P&gt;toDate = ${date:now+1M:YYYY-MM-dd}&lt;/P&gt;
  &lt;P&gt;fromDate = ${date:now-1M:YYYY-MM-dd}&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2033518-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;I tried these and it create 2 properties with same current date.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2033519-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2033521-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Is it working?&lt;/P&gt;
  &lt;P&gt;Camel Reference: &lt;A href="https://camel.apache.org/components/3.15.x/languages/simple-language.html"&gt;https://camel.apache.org/components/3.15.x/languages/simple-language.html&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2033522-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;(I'm trying to remove groovy date calculations)&lt;/P&gt;
  &lt;P&gt;Federico Bellizia&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 17:08:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaq-p/12494913</guid>
      <dc:creator>bellizia_pwc</dc:creator>
      <dc:date>2022-03-25T17:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: SCPI: CF: Date camel expression use</title>
      <link>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/12494914#M4682083</link>
      <description>&lt;P&gt;Hi Federico&lt;/P&gt;&lt;P&gt;This is a very interesting question! I had to do quite a bit of digging to find the answer, so thank you for asking it &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;First off, the date offsets only support milliseconds, seconds, minutes and hours. You can add or subtract a day (= 24 hours), or a week ( = 7 * 24 hours = 168 hours) but not a month, since the number of hours depends on the month in question.&lt;/P&gt;&lt;P&gt;No, this does not seem to be mentioned in neither the Apache Camel Simple documentation nor the Cloud Integration documentation, and that's pretty annoying.&lt;/P&gt;&lt;P&gt;What's happening with your specific example is that the uppercase "M" is treated as a lowercase "m", i.e. as an offset in minutes. You can verify this by adding "HH:mm" to your date pattern.&lt;/P&gt;&lt;P&gt;I believe I've located the code that does the conversion from offsets to milliseconds (it's &lt;A href="https://github.com/apache/camel/blob/camel-2.24.2/camel-core/src/main/java/org/apache/camel/converter/TimePatternConverter.java" target="_blank"&gt;here&lt;/A&gt;), and it's fairly clear from it why this is happening:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2036540-case-insensitive.png" /&gt;&lt;/P&gt;&lt;P&gt;That's not a bug, mind you, since the code doesn't support months as an offset.&lt;/P&gt;&lt;P&gt;So you can't achieve your goal using Apache Camel Simple. But even if you could, I'm not sure that you should. It looks to me like every time a Simple date expression is evaluated, a new Date object is created. This opens the door to a race condition, where the first property is created immediately &lt;EM&gt;before&lt;/EM&gt; the month changes, and the second one is created immediately &lt;EM&gt;after&lt;/EM&gt;. That would give an unexpected result.&lt;/P&gt;&lt;P&gt;To sum up: You need to create the properties in a Groovy script, and make sure to use the same point in time as the basis for both.&lt;/P&gt;&lt;P&gt;Have fun with CPI and thanks again for asking a really interesting question!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Morten&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 23:05:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/12494914#M4682083</guid>
      <dc:creator>MortenWittrock</dc:creator>
      <dc:date>2022-03-25T23:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: SCPI: CF: Date camel expression use</title>
      <link>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/12494915#M4682084</link>
      <description>&lt;P&gt;Thank you for very good answer, that's another missing feature.&lt;/P&gt;&lt;P&gt;INSESITIVE in that place tell a lot of low sensitivity to this problem.&lt;/P&gt;&lt;P&gt;I will return to use groovy script for +1 month on date.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 08:19:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/12494915#M4682084</guid>
      <dc:creator>bellizia_pwc</dc:creator>
      <dc:date>2022-03-28T08:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: SCPI: CF: Date camel expression use</title>
      <link>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/12494916#M4682085</link>
      <description>&lt;P&gt;Happy to help!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Morten&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 08:47:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/12494916#M4682085</guid>
      <dc:creator>MortenWittrock</dc:creator>
      <dc:date>2022-03-28T08:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: SCPI: CF: Date camel expression use</title>
      <link>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/13771664#M4838322</link>
      <description>&lt;P&gt;Hi Morten&lt;/P&gt;&lt;P&gt;....impressive that there is no reference on this anywhere...I had the same issue and solution was found only in your reply (thumbs up!!!)&lt;/P&gt;&lt;P&gt;Other References&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://camel.apache.org/components/4.4.x/languages/simple-language.html" target="_self"&gt;Camel Components / Language / Simple (for v4.4)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://camel.apache.org/components/4.4.x/languages/file-language.html#_samples" target="_self"&gt;Date usage samples&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and even in SAP Help (&lt;A href="https://help.sap.com/docs/cloud-integration/sap-cloud-integration/camel-data-model-in-nutshell" target="_self"&gt;camel-data-model-in-nutshell&lt;/A&gt;&amp;nbsp;) the documentation is on high level.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 09:57:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scpi-cf-date-camel-expression-use/qaa-p/13771664#M4838322</guid>
      <dc:creator>mmastora</dc:creator>
      <dc:date>2024-07-25T09:57:07Z</dc:date>
    </item>
  </channel>
</rss>

