SWT DateTime format change

旧城冷巷雨未停 提交于 2019-12-10 14:04:09

问题


I'm using a DateTime SWT component, and it has an American format when displayed (mm/dd/yyyy).

Is there any way to change the format to dd/mm/yyyy ?


回答1:


DateTime uses the OS specific user preferences to format the date. (On Windows these are the Regional and Language Options in the system settings).

A possible workaround is described here (scroll down to the latest two entries). But I haven't tried this myself.




回答2:


You need to set the locale to change the date format, e.g. to Italy who use dd/mm/yyyy:

Locale.setDefault(Locale.ITALY);

An alternative is the Nebula CDateTime Widget: https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php

(btw: if you are using Linux there is a bug regarding the locale: https://bugs.eclipse.org/bugs/show_bug.cgi?id=248075)



来源:https://stackoverflow.com/questions/34632492/swt-datetime-format-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!