xpageslotus-dominoxpages-ssjs

How to change Java toLocalizedPattern() date format in windows?


My below java code prints the date format as shown below.

var pattern:java.lang.String = (new java.text.SimpleDateFormat()).toLocalizedPattern();
print("Pattern===>"+pattern)

enter image description here.

Expected Date Format: dd/MM/yyyy Actual Date format: M/d/yy

I am not sure from where this date format is getting picked up. I have changed all the settings at windows level. My domino date setting also changed as shown below.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Do we have any specific java policy needs to be updated with dd/MM/yyyy date format?


Solution

  • You might be asking the wrong question. If you send data to a client UI, send ISO Date and let the intl JS object handle the visualization. This will cater to the user's formatting preferences.

    You can use the DateTimeFormatter if you want to stay server side.

    Also note: When your Domino server runs as a service, the user locale gets ignored and the system locale is used.

    This ServerVault entry and this external support shed some light on it.

    I still would leave the rendering to front-end code.