How to change programmaticaly the preferences item corresponding to the locale of datetime format

조회 수: 4 (최근 30일)
I try this command, there is no error but it doesn't work :
com.mathworks.services.Prefs.setStringPref('Locale','fr_FR');
I am looking for the preference name equivalent to : Preferences -> Command Window -> Datetime format -> Locale
I don't found it in matlab.prf

답변 (1개)

Suraj Kumar
Suraj Kumar 2024년 11월 24일
Preferences related to the Command Window, including the datetime format, are typically not directly accessible or modifiable through the matlab.prf file. However, you can programmatically set the datetime format for your session using MATLAB commands.
To set the datetime format to a specific locale programmatically, you can use the datetime.setDefaultFormats function:
datetime.setDefaultFormats('default','yyyy-MM-dd hh:mm:ss')
To learn more about the datetime function in MATLAB, please refer to the following documentation link:
Hope this works for you!
  댓글 수: 1
Laurent
Laurent 2024년 11월 25일
Thanks for your answer.
With datetime.setDefaultFormats unfortunately it can't set the locale language.
Changing via Preferences -> Command Window -> Datetime format -> Locale works correctly on MATLAB Online but it does not exist on MATLAB Mobile.
So I try to use com.mathworks.services.Prefs.setStringPref without success.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by