Java != Java on Domino

Wednesday, January 8, 2025 at 6:07 PM UTC

Today I again encountered some strange things on different Domino machines. It’s Java again. The other specs are:

  • my local dev box is 12.0.2FP2, running in a container using the HCL image
  • the other machines are natively installed 12.0.2FP2, also Linux
  • there are no language packs installed at all

The parts that are used:

  • some Java in an NSF, defined as managed bean (but this doesn’t matter)
  • Java is using ExtLibUtil and java.util.Calendar
  • some XSP in an NSF

How to reproduce

Create an new NSF on your machine.

Create a new Java class org.openntf.XspHelper.

Create an entry for the bean in faces-config.xml like this:

<managed-bean> 
    <managed-bean-name>xsp</managed-bean-name> 
    <managed-bean-class>org.openntf.XspHelper</managed-bean-class> 
    <managed-bean-scope>view</managed-bean-scope> 
</managed-bean> 

 

Create two methods in the class:

public String getBrowserLocale() {
    return ExtLibUtil.getXspContext().getLocale().getDisplayLanguage().toLowerCase();
}

public String getTodayString() {
    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd, HH:mm:ss");
    StringBuilder sb = new StringBuilder();
    Calendar cal = Calendar.getInstance();
    sb.append(sf.format(cal.getTime()));
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    sb.append(" ----> ");
    sb.append(sf.format(cal.getTime()));
    sb.append(" - ");
    cal.add(Calendar.DATE, 8);
    sb.append(sf.format(cal.getTime()));
    return sb.toString();
}

Create a new XPage env.xsp and place this on it:

Browser language detected:&#160;
<xp:text value="#{javascript:xsp.getBrowserLocale()}"></xp:text>
<br />
Date range based on today's date, starting on SUNDAY (should be the sunday BEFORE today's date):&#160;
<xp:text value="#{javascript:xsp.getTodayString()}"></xp:text>

Observed behaviour

My dev box displays this (current date was Jan 8, 2025):

The other machines display this:

If you don’t see it: the locale string is localised itself which is strange. Even more strange is the fact that the date of the week’s SUNDAY is calculated in a different way, the other machine sets it to the next Sunday, my box to the one before the current date.

WTF?

So, if anyone knows what is going on here, how to configure it equally and if this maybe is a bug, please drop me a note!

BTW

Happy New Year!

Update

It seems that the 2 servers think they have to handle weeks differently, esp. the first day of the week. In this case it's SUNDAY, like in the US. My machine acts like it should be in my case, which is MONDAY as in almost every middle European country. The solution is to staticly define the start of the week accordingly:

cal.setFirstDayOfWeek(Calendar.MONDAY);






Latest comments to this post

Oliver wrote on 09.01.2025, 21:21

Hi Paul,

locale on the docker Domino from HCL gives:

LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

where a locale on the other box is this:

LANG=en_US.UTF-8
LANGUAGE=en_US.utf8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

so this also does not quite fit my observations.

 Link to this comment
Paul Withers wrote on 09.01.2025, 18:42

I don't have a definitive answer, but Calendar.getInstance() without arguments gets a Calendar instance using the default locale (server-side). But the output you print never identifies what the server's default locale is. The output implies they're different. Maybe java.util.Locale's getDefault() method will show they're different.

The browser language is client-side and I don't know how ExtLibUtil calculates it - it's been a while since I looked at the source code in the OpenNTF project. But the fact one gives "german" and the other gives "deutsch" looks suspiciously like the server locales are different.

The question then is whether this is indeed being driven by Domino settings or OS settings of locale. A simple jar file to print the output from java.util.Locale and java.util.Calendar would be a good check, to remove any potential impact of Domino from the equation. It's may also be worth using Linux commands to check, to definitively get the answer at OS level, removing all layers of abstraction. But it looks suspiciously like the default locale somewhere is different, possibly US on the HCL image.

 Link to this comment

Leave a comment right here