how to format date globally

Hi,

I want to format date appearance everywhere from dd/MM/yyyy to yyyy-MM-dd globally. In database not necessary. I know I can change it in xmls, but I don’t want to set it in every screen. I have about 12 Entity and every entity has a browser and an editor screen and maybe i will have more screens. So I need this date the mentioned format. Is there one place where I can change it and everywhere will be my date format?
I hope I was understandable.

Thank you,
Carol

Hi Carol,

Edit “Project Properties” in Studio, click button in the “Available locales” field, in the opened dialog click “Show data format strings” and enter

  • dateTimeFormat: yyyy-MM-dd HH:mm

  • dateFormat: yyyy-MM-dd

Restart your app server.

See docs for explanation.

Hi,

It worked till now, I wanted to give a dateTime: yyyy.MM.dd HH:mm , but when I give Cuba “2016.10.13 15:16” then for the hour and minute I get an “Input Error”. By default time is 12 hour? How to change to 24 hour?

Thank you!

Hi Karolina,

as it seems you want to have the german version of the platform i would encourage you to just download the german translations. It already includes the correct dateTime configurations.

It is based on the translation project on github: https://github.com/cuba-platform/translations
Matthias created a application-component out of it (https://github.com/bresche/translation-german), so you basically just have to download it, import it into studio and do a “Run > Install app component”. After that you add the dependency to your project either via studio or directly in the build.gradle and you should be good to go…

I hope this helps - although not answering your question directly :slight_smile:

Bye

Hi Mario,

Yes, you are close to the truth. I need hungarian format, which is the same like german, they are in neighbor, but if I install that app-component, my translations will be stay? Or will they change to german?

Thank you,
Karolina

I would assume it does not conflict because as you can see here: https://github.com/bresche/translation-german/blob/master/modules/global/src/com/haulmont/cuba/core/messages_de.properties

the files are named as messages_de.properties.
There can be different messages files for different languages that distingluish each other by the postfix of the file. So iy you named your stuff messages_hun.properties and not messages_de.properties it should not change anything, just add another language.

But in case you don’t need german translation, you can also just go ahead and do the direct editing of the dataTime values…

Bye

Please could you tell me how to import german app-component or specify how to edit dateTime values?
And thanks for your replies!

Okay, so I still do not know how to change dateTime to 24 hour, I really searched for it everywhere, in that German project I still didn’t find anything like that…

Hi,

How have you specified the format? Is the “HH” in uppercase?


dateTimeFormat: yyyy-MM-dd HH:mm

Ensure it. If the problem persists and you still have 12-hour format, could you zip and share the project here? Or prepare a simple sample project which could illustrate the problem.

format

Hi Rostislav,

Yes, I attached a photo, and HH is uppercase. But I found a messages-properties file at myProject\modules\web\build\resources\main\com\company\myproject\web\messages_hu.properties and that includes these:


cuba.availableLocales = Magyar|hu, Magyar|hu
dateTimeFormat = yyyy.MM.dd hh:mm:ss
dateFormat = yyyy.MM.dd
application.caption = MyProject
application.logoImage = branding/app-icon-menu.png

And when I change hh to HH, and run project and try it, then when I put time “15:34” I get the Input error and this file changes back to lowercase hh. How is this possible? I guess this is the problem. And in Cuba there is line like -, but on web where is the input field there are dots…

dateTime

Look at the path to the file. It is inside the build folder so it is rewritten on every project build.

Modify modules/web/src/com/company/myproject/web/messages_hu.properties or adjust the format using Studio.

1 Like

exist an italian version translation ?