简体   繁体   English

SWT DateTime格式更改

[英]SWT DateTime format change

I'm using a DateTime SWT component, and it has an American format when displayed (mm/dd/yyyy). 我正在使用DateTime SWT组件,它显示时为美国格式(mm / dd / yyyy)。

Is there any way to change the format to dd/mm/yyyy ? 有没有办法将格式更改为dd / mm / yyyy?

DateTime uses the OS specific user preferences to format the date. DateTime 使用特定于操作系统的用户首选项来格式化日期。 (On Windows these are the Regional and Language Options in the system settings). (在Windows上,这些是系统设置中的区域和语言选项)。

A possible workaround is described here (scroll down to the latest two entries). 此处描述一种可能的解决方法(向下滚动到最新的两个条目)。 But I haven't tried this myself. 但我自己没试过。

You need to set the locale to change the date format, eg to Italy who use dd/mm/yyyy : 您需要设置区域设置以更改日期格式,例如,使用dd / mm / yyyy的意大利:

Locale.setDefault(Locale.ITALY);

An alternative is the Nebula CDateTime Widget: https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php 另一个是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 ) (顺便说一下:如果您使用的是Linux,那么有关于语言环境的错误: https//bugs.eclipse.org/bugs/show_bug.cgi?id = 248075

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM