Strange Behavior in the CDateTime Nebula

I am trying CDateTime as a cell editor for my swt control. When I run a separate CDateTime sample (from here ), it looks like this:

Regular CDT behavior

CDateTime is created as follows:

final CDateTime cdt = new CDateTime(shell, CDT.DROP_DOWN | CDT.DATE_SHORT | CDT.COMPACT); cdt.setSelection(new Date()); 

Pay attention to the icon causing the dropout - it looks like a calendar. You can see the month / year, and there are 2 arrow buttons and a Today button in the left corner of the header. The date is also written to the text box correctly when you select the date.

However, when I try to add it as a cell editor, it looks like this:

CDateTime as a cell editor

Note that the icon is different, and parts of the title are different. Also notice how I chose the date and get this strange number - with month 32! - in the text box. When the popup disappears, the date is correct, but this strange behavior looks strange and worries.

I created a CDateTime as follows:

  final int style = getStyle() | CDT.DATE_SHORT | CDT.DROP_DOWN | CDT.COMPACT ; this.dateTime = new CDateTime(parent, style); this.dateTime.setPattern("mm/dd/yyyy"); 

What am I doing wrong?

+6
source share
1 answer

I know this is an old question, but here is the answer: the template you set is incorrect, "mm" represents minutes. instead, you can use "MM" to get the month:

  dateTime.setPattern("MM/dd/yyyy"); 
+1
source

Source: https://habr.com/ru/post/986228/


All Articles