# Error Parsing String with String to Date&Time

**URL:** <https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549>\
**Category:** KNIME Analytics Platform\
**Created:** [January 3, 2022, 7:48pm UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549 "2022-01-03T19:48:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![christiam](https://forum-cdn.knime.com/user_avatar/forum.knime.com/christiam/32/34588_2.png) [@christiam](https://forum.knime.com/u/christiam)\
**Post date:** [January 3, 2022, 7:48pm UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/1 "2022-01-03T19:48:10Z")

</div>

I’ve just updated to Knime v.4.5 and I got a parse error with a workflow that I had run hundreds of times before the update (without any error). The format of the dates and times I want o parse is:  
**30/08/2021 06:32:54 PM**  
As format to parse I am using:  
**dd/MM/yyyy hh:mm:ss a**  
When attempting to run, I get the message “ **Execute failed: Failed to parse date…** ” with the string that I showed before.

Community, any ideas to what to check or fix?

---

<div class="post-metadata">

**Author:** ![Thyme](https://forum-cdn.knime.com/user_avatar/forum.knime.com/thyme/32/34550_2.png) [@Thyme](https://forum.knime.com/u/Thyme)\
**Post date:** [January 3, 2022, 8:48pm UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/2 "2022-01-03T20:48:30Z")

</div>

Hi @christiam,

I assume this problem occured with the String to Date&Time Node? You’re right, from how I understand the format specifiers this should indeed work (but it doesn’t).  
However, I was able to get the node to work by changing the locale from de-AT to en-US. I hope that gets you back online until someone from the team can comment on this.

Happy New Year, T

[String to Date&Time – Node Documentation](https://hub.knime.com/knime/extensions/org.knime.features.base/latest/org.knime.time.node.convert.stringtodatetime.StringToDateTimeNodeFactory)  
[DateTimeFormatter (Java Platform SE 8 ) (oracle.com)](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html)

 ![parse_error](https://forum-cdn.knime.com/uploads/default/original/3X/b/b/bbdec687285b0bc3de07b444fcbadd555149cdee.png)

---

<div class="post-metadata">

**Author:** ![takbb](https://forum-cdn.knime.com/user_avatar/forum.knime.com/takbb/32/57077_2.png) [@takbb](https://forum.knime.com/u/takbb)\
**Post date:** [January 4, 2022, 12:29am UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/3 "2022-01-04T00:29:37Z")

</div>

Hi @christiam and @Thyme, this is an issue that came about with the move to a later version of java as the date handling changed from what it used to be (in the java 8 documentation that you have referenced).

@christiam… Did you upgrade from knime 4.3 or 4.4? I think it was probably from KNIME 4.3 as I believe your data would have worked with that version, but not with 4.4 and above.

This was a change in the underlying java date handling and not a direct change in knime. For some locales, the AM/PM now has to be in lower case instead of upper case for the date conversion to work.

There is a config setting that I have detailed in the following post, which you may find of use of this is causing problems…

> [@String to Date&Time worked on previous knime version but having issues with current version (4.4.1)](https://forum.knime.com/t/string-to-date-time-worked-on-previous-knime-version-but-having-issues-with-current-version-4-4-1/36507/3):
>
> BUT… in spite of my previous reply you are right @Sajith !! I was surprised about the case of the AM/PM, as I thought it should be upper case, so I just went and tried it in KNIME 4.3.4 Using the format mask dd/MM/yyyy h:mm a KNIME 4.3.4, converts 16/09/2021 6:07 PM KNIME 4.4.1 converts 16/09/2021 6:07 pm They both complain about the opposite case. (I was testing this using locale en-AU as per the screenshot. The result of other locales may vary I guess) Likewise the “a” in the “Date & T…

Hope that helps, and explains why it doesn’t now always work the way you (and I) previously expected.

---

<div class="post-metadata">

**Author:** ![Thyme](https://forum-cdn.knime.com/user_avatar/forum.knime.com/thyme/32/34550_2.png) [@Thyme](https://forum.knime.com/u/Thyme)\
**Post date:** [January 4, 2022, 7:50am UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/4 "2022-01-04T07:50:22Z")

</div>

Hi @takbb,  
I suspected the problem to be caused by a change coming from Java, thanks for confirming that. It doesn’t work with lower case AM/PM though, that’s the first thing I tried. In fact, it has to be upper case, even with the en-US locale. de-AT doesn’t work either way. Still a good reference for future people, thanks.

---

<div class="post-metadata">

**Author:** ![takbb](https://forum-cdn.knime.com/user_avatar/forum.knime.com/takbb/32/57077_2.png) [@takbb](https://forum.knime.com/u/takbb)\
**Post date:** [January 4, 2022, 8:45am UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/5 "2022-01-04T08:45:52Z")

</div>

Hi @Thyme (and @christiam ), As I haven’t previously tried non English based locales, I thought I’d have a look at this.

The java locale changes for AM/PM time handling are now (very) language dependent.

I put together a quick test workflow to see what the expected values are for different locales en-US, en-GB, de-AT

As you have already indicated, en-US remains with upper case AM/PM, so I used that to convert the sample date/times into a datetime column, and then tried converting back using each of these three locales.

![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/3/e39e0e7a0661797266c1e44919ce14ccc139cff0.png)

This is the result:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/d/bd6994c79cc7c9c0aaf02d908d1a4c0152a8d340.png)

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/0/8/08f228309662301b9889365a6eceff50e0cb5cd7.png)

![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/9/7922f626b877dd033aed30d884b6d67d6cc2957d.png)

As can be seen, the en-US remains as `AM/PM`, en-GB has changed case to `am/pm`, and de-AT uses `nachm./vorm.`

[Date time format change.knwf](https://forum.knime.com/uploads/short-url/rYFWOd29j7YQMh63PtB3kjgthdG.knwf) (13.0 KB)

The compatibility setting mentioned in the previously referenced post should cause java (and therefore KNIME) to behave the old way, but as you have found, using the locale of en-US is also a way forward (and probably the better way forward), if the time format matches that particular locale. I would suggest only use the compatibility setting if you have a large number of workflows that now fail, and/or you don’t ever receive data that is generated using the new locale formats.

**Note**  
If you run KNIME with the compatibility setting in the KNIME.INI file…

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/f/9f4813b6994840051c89e9700d5b48f8d4b62400.png)

… all three locales will require and generate the same AM/PM in the attached workflow:  
e.g.  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/9/99ec8b0714c6ea7f9c845f4076600de992076dfc.png)

---

<div class="post-metadata">

**Author:** ![Thyme](https://forum-cdn.knime.com/user_avatar/forum.knime.com/thyme/32/34550_2.png) [@Thyme](https://forum.knime.com/u/Thyme)\
**Post date:** [January 4, 2022, 1:38pm UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/6 "2022-01-04T13:38:34Z")

</div>

Going one step further (or back?) to verify the solution is quite smart! Shows how to solve the same issue for the hundreds of other Locales.  
Since those changes potentially add confusion to the already mind-boggling problem of timezones and DSTs, my advice is to use ISO formatted UTC timestamps whenever possible (generally, not only here). No timezones, no daylight savings, no problems. At least until you have to display that to the user 😅

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [January 11, 2022, 1:39pm UTC](https://forum.knime.com/t/error-parsing-string-with-string-to-date-time/38549/7 "2022-01-11T13:39:26Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
