DateTime widget with 12h format not working [message #756721] |
Mon, 14 November 2011 14:42  |
Eclipse User |
|
|
|
I want to make sure this is a bug before posting it on bugzilla.
I'm running eclipse indigo, on windows 7, Java 1.6.
When you set the time format in windows to 12h and select 12:00:00 PM in the DateTime widget, calling getHours() on the widget return 12. It should return 24.
final DateTime time = new DateTime(parent, SWT.TIME);
Button ok = new Button(parent, SWT.PUSH);
ok.setText("OK");
ok.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
System.out.println(time.getHours());
}
});
Thanks in advance.
|
|
|
|
|
|
|
Re: DateTime widget with 12h format not working [message #756925 is a reply to message #756888] |
Tue, 15 November 2011 09:53   |
Eclipse User |
|
|
|
Midnight is 12:00AM on a 12-hour clock. The snippet below sets and then
gets the noon and midnight hours, it works for me on Windows 7.
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
new Label(shell, SWT.NONE).setText("Noon:");
DateTime dt1 = new DateTime(shell, SWT.TIME);
dt1.setTime(12, 0, 0);
new Label(shell, SWT.NONE).setText("Midnight:");
DateTime dt2 = new DateTime(shell, SWT.TIME);
dt2.setTime(0, 0, 0);
shell.pack();
shell.open();
System.out.println("Noon hour: " + dt1.getHours());
System.out.println("Midnight hour: " + dt2.getHours());
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
On 11/15/2011 7:46 AM, Loris wrote:
> Yes, but you can't enter 00:00 AM in the widget, entering 00:00 AM and
> changing focus triggers an automatic change from 00:00 AM to 12:00 PM.
|
|
|
Re: DateTime widget with 12h format not working [message #756978 is a reply to message #756925] |
Tue, 15 November 2011 15:19  |
Eclipse User |
|
|
|
You're right Grant.
Midnight is 12:00:00 AM and 12:00:00 PM is noon.
Simply put, after 11:59:59 PM comes 12:00:00 AM.
As it turns out it's a matter of understanding the 12h format, if an Admin considers it's not a relevant Topic please delete it.
Thanks everybody for the help.
|
|
|
Powered by
FUDForum. Page generated in 0.03620 seconds