0

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?

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • 1
    Isn’t your server in charge of the format and not the client? Would need reboot – stwissel Jun 19 '23 at 17:38
  • Thanks for replying. All these pictures from Server only. I did reboot several times both domino and windows. still same format is coming. NotesInternational class is returning "DMY" properly. Only Java has this format issue. – user3493803 Jun 19 '23 at 17:46
  • 1
    "*where this date format is getting picked up*" : as explained in the [documentation](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/text/SimpleDateFormat.html#%3Cinit%3E()): "*Constructs a `SimpleDateFormat` using the default pattern and date format symbols for the default `FORMAT` locale.*" || (no idea what `v` is in posted code) – user16320675 Jun 19 '23 at 17:47
  • Thanks. Do we have any specify place we can find this `FORMAT` locale on windows or Java? (removed unwanted line) – user3493803 Jun 19 '23 at 17:57
  • What is your *real code*? You should be using `DateTimeFormatter` – g00se Jun 19 '23 at 18:04
  • 1
    I'm not sure if it's possible, check this question and answer, https://stackoverflow.com/a/6743553/17758716. – Reilas Jun 19 '23 at 18:07
  • Don't describe the code you think you need or the steps. Describe the [GOAL](http://technojeeves.com/joomla/index.php/free/117-smart-questions) – g00se Jun 19 '23 at 18:19
  • The images don't help. Please describe your problem in a paragraph or two and use simple formatted strings to show before, after, and expected output. – WJS Jun 19 '23 at 22:17

1 Answers1

3

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.

stwissel
  • 20,110
  • 6
  • 54
  • 101
  • 1
    Thanks Stephen, [external support](https://kb.firedaemon.com/support/solutions/articles/4000086159-how-to-change-your-windows-services-locale) worked. Ensure that "Welcome screen and system accounts" is checked, as well as "New user accounts". This ensures that locale settings are copied for existing users, system accounts (i.e. service accounts including domino) and new user accounts. – user3493803 Jun 20 '23 at 04:23