There are two methods for setting which components of a date and/or a time you want your users to be able to select: 1. the easy way; or 2. the other way.
CDateTime.setFormat accepts a single bit-wise OR-ed int corresponding to the three types of java.util.DateFormat:
| CDateTime.setFormat(CDT.DATE_XXX) | DateFormat.getDateInstance(DateFormat.XXX) |
| CDateTime.setFormat(CDT.TIME_XXX) | DateFormat.getTimeInstance(DateFormat.XXX) |
| CDateTime.setFormat(CDT.DATE_XXX | CDT.TIME_YYY) | ![]() |
| DateFormat.getDateTimeInstance(DateFormat.XXX, DateFormat.YYY) |
CDT.java contains the following style constants:
| DATE_SHORT | TIME_SHORT |
| DATE_MEDIUM | TIME_MEDIUM |
| DATE_LONG |
Example:
CDateTime cdt = new CDateTime(parent, CDT.BORDER | CDT.DROP_DOWN);
cdt.setFormat(CDT.TIME_SHORT);

Note that date and time styles can also be used in the constructor:
new CDateTime(parent, CDT.BORDER | CDT.DROP_DOWN | CDT.TIME_SHORT);
Under the covers, CDateTime uses java.text.SimpleDateFormat to format its text and assist in the navigation of its fields. Because of this, any pattern that can be passed to SimpleDateFormat can be used (refer to the SimpleDateFormat Javadoc)
Example:
CDateTime cdt = new CDateTime(parent, CDT.BORDER | CDT.DROP_DOWN);
cdt.setPattern("'Meeting on' EEEE, MMMM d '@' h:mm 'in the'a");

Caveats and Special Considerations: