Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » DateTime widget with 12h format not working
DateTime widget with 12h format not working [message #756721] Mon, 14 November 2011 19:42 Go to next message
Lorand Lorincz is currently offline Lorand LorinczFriend
Messages: 35
Registered: April 2011
Member
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 #756738 is a reply to message #756721] Mon, 14 November 2011 21:05 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Technically 12:00:00PM doesn't exist. An AM/PM designation doesn't make sense for noon or midnight. When 12:00:00PM is used, it is generally considered to be noon so it would be represented by 12 for a 24 hour clock.
Re: DateTime widget with 12h format not working [message #756839 is a reply to message #756738] Tue, 15 November 2011 10:15 Go to previous messageGo to next message
Lorand Lorincz is currently offline Lorand LorinczFriend
Messages: 35
Registered: April 2011
Member
Ok, but 11:59:59 PM return 23 hours, and entering 00:00:00 PM automatically changes the widget to 12:00:00 PM. This means it's not possible to represent in the 12h format the time 00:00:00 which exists in the 24h format. More simpler put, how do you represent midnight in the 12h format with the DateTime widget?
Re: DateTime widget with 12h format not working [message #756882 is a reply to message #756839] Tue, 15 November 2011 12:34 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Wouldn't it be 00:00 AM ?

Re: DateTime widget with 12h format not working [message #756888 is a reply to message #756882] Tue, 15 November 2011 12:46 Go to previous messageGo to next message
Lorand Lorincz is currently offline Lorand LorinczFriend
Messages: 35
Registered: April 2011
Member
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 #756925 is a reply to message #756888] Tue, 15 November 2011 14:53 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
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 20:19 Go to previous message
Lorand Lorincz is currently offline Lorand LorinczFriend
Messages: 35
Registered: April 2011
Member
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.
Previous Topic:Activity pattern binding to remove "Previous/Next Annotation" and "Last Edit Location
Next Topic:two platforms
Goto Forum:
  


Current Time: Thu Apr 25 09:55:54 GMT 2024

Powered by FUDForum. Page generated in 0.03093 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top