# Joda error allthough adding locale

**URL:** <https://community.openhab.org/t/joda-error-allthough-adding-locale/157320>\
**Category:** Scripts & Rules\
**Created:** [July 21, 2024, 9:30am UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320 "2024-07-21T09:30:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver2](https://community.openhab.org/letter_avatar_proxy/v4/letter/o/df705f/32.png) [@Oliver2](https://community.openhab.org/u/Oliver2)\
**Post date:** [July 21, 2024, 9:30am UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320/1 "2024-07-21T09:30:14Z")

</div>

I get the following error message:

```auto
Failed to execute script: i: Pattern using (localized) text not implemented, use @js-joda/locale plugin!

```

As documented, I installed a Locale by `npm install @js-joda/locale_de-de` in the $OPENHAB\_CONF/automation/js folder.  
Here is the code:

```javascript
var Locale = require('@js-joda/locale_de-de').Locale.GERMAN;
console.log(time.LocalDateTime.now().format(time.DateTimeFormatter.ofPattern("EEEE, yyyy-MM-dd'T'HH:mm:ss").withLocale(Locale)));

```

Permissions are set correctly.  
Where is my fault?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [July 21, 2024, 4:37pm UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320/2 "2024-07-21T16:37:44Z")

</div>

The npm install completed without error? Do you see the folder `$OH_CONF/automation/js/node_modules/@js-joda/locale_de-de` and does it have contents?

Have you restarted OH since installing the node module? That shouldn’t be necessary but 🤷‍♂️.

What’s the setting Cache setting for the JS Scripting add-on?

---

<div class="post-metadata">

**Author:** ![Oliver2](https://community.openhab.org/letter_avatar_proxy/v4/letter/o/df705f/32.png) [@Oliver2](https://community.openhab.org/u/Oliver2)\
**Post date:** [July 23, 2024, 10:44am UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320/3 "2024-07-23T10:44:42Z")

</div>

Yes, I have restarted OH and I can see the locale folder including its content:  
/etc/openhab/automation/js/node\_modules/@js-joda/locale\_de-de/dist `

```auto
-rw-r--r-- 1 openhab openhab 328264 Jul 20 23:49 index.esm.js
-rw-r--r-- 1 openhab openhab 262973 Jul 20 23:49 index.esm.js.map
-rw-r--r-- 1 openhab openhab 359043 Jul 20 23:49 index.js
-rw-r--r-- 1 openhab openhab 263063 Jul 20 23:49 index.js.map
-rw-r--r-- 1 openhab openhab 180615 Jul 20 23:49 index.min.js
-rw-r--r-- 1 openhab openhab 2328 Jul 20 23:49 js-joda-locale.d.ts

```

JS settings are set to

- Integrated Variables
- Cache Library Injection

It does not make any difference if I change the settings.

Forgot to mention that I am using Java 21.

EDIT: I had to install @js-joda/timezone, too. But the error is still there.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [July 23, 2024, 1:14pm UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320/4 "2024-07-23T13:14:45Z")

</div>

I managed to do some experiments yesterday and I’m seeing the same error. I know this worked at some point so I think there is a bug or regression or the like that has cropped up. To start file an issue on openhab-js and see where that goes.

I’ve also tried it with `e` instead of `E` as [the docs](https://js-joda.github.io/js-joda/manual/formatting.html) indicate that’s the localized string but get the same error. I get no error if I remove the “EEEE” part and leave the rest which shows it is not some other type of general formatting problem.

---

<div class="post-metadata">

**Author:** ![Oliver2](https://community.openhab.org/letter_avatar_proxy/v4/letter/o/df705f/32.png) [@Oliver2](https://community.openhab.org/u/Oliver2)\
**Post date:** [March 23, 2025, 5:22pm UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320/5 "2025-03-23T17:22:06Z")

</div>

Quite a while, but I found the prolem. It needs to be

```javascript
console.log(java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("EEEE, yyyy-MM-dd'T'HH:mm:ss").withLocale(java.util.Locale.GERMAN)));

```

instead of

```javascript
var Locale = require('@js-joda/locale_de-de').Locale.GERMAN;
console.log(time.LocalDateTime.now().format(time.DateTimeFormatter.ofPattern("EEEE, yyyy-MM-dd'T'HH:mm:ss").withLocale(Locale)));

```

just to let you know as you also experienced the same problem.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [March 25, 2025, 3:09pm UTC](https://community.openhab.org/t/joda-error-allthough-adding-locale/157320/6 "2025-03-25T15:09:09Z")

</div>

> [@Oliver2](#):
>
> . It needs to be

keep in mind that’s using Java’s date time classes, not joda-js. They are not the same and they are not compatible.
