0

today I have a really strange problem. I will try to explain it as best as I can. So the line where it fails is the third one:

LocalDateTime.parse(
    this.text,
    DateTimeFormatter.ofPattern("EE' 'dd.MM.yyyy, kk:mm 'Uhr'")
).toKotlinLocalDateTime()

If I execute the test via intellij it works with success: Intellij Tests

If i execute it via the cli or in the pipeline it get this error:

CMD Test/Pipeline

The Date that i try to parse ist this line: "Mo. 19.09.2022, 08:00 Uhr"

Maybe some of you has an idea how to solve the issue?

You can find the code also here: https://gitlab.com/thw2/training-plan/api and the CICD Pipeline here: https://gitlab.com/thw2/training-plan/api/-/jobs/3199115286

  • 1
    maybe it is a `Locale` problem (different default in IDE) try using `localizedBy(Locale.GERMAN)` (or similar) on the `DateTimeFormatter` (the error message is a bit strange/small... but I am not a Kotlin user, just Java) – user16320675 Oct 19 '22 at 21:30
  • 1
    (the weekdays are formatted differently depending on `Locale`: "Mon" for English, "Mo." for German [my guess, obviously you should use the appropriate `Locale` ]) BTW `kk` (1-24 hour) would be strange for Germany; maybe `HH` (0-23 hour) – user16320675 Oct 19 '22 at 21:41
  • 1
    Yes, HH in Germany for hours 0 - 23 – Christoph S. Oct 19 '22 at 21:50
  • 2
    (also check the `withLocale()` method of `DateTimeFormatter`, probably the better option) – user16320675 Oct 19 '22 at 21:52
  • 2
    Other possibilities might include different versions of Java or Kotlin, or characters that differ while looking the same (e.g. non-breaking spaces or curly quotes). But yes, the locale is more likely to be an issue — well spotted! – gidds Oct 19 '22 at 22:09
  • Oh guys you are really amazing thanks that was the solution! – Daniel Pfeil Oct 20 '22 at 06:36

0 Answers0