Calendar spinner

The calendar spinner displays and spins the date and time. The date and time values can be changed by clicking on different sub fields and spinning on them. Alternatively, you can type in a date string to set the current value.

Properties

Property Description Data Type Flags* Default Value Valid Value
wrapAssociated Marks whether the changes of different field values of the date are associated. For example if wrapAssociated is true and the current value is "1998,12", the year will change from 1998 to 1999 when the value of the month is incremented. boolean R, W, B True True - different field values are associated
False - different field values are not associated
timeZone Represents a time zone offset. It is also makes changes for daylight savings time. String R, W, B The system's local time zone. valid time zone string
year The year int R, W, B, E The system's current year. valid year
month The month
Note: the property value of month is from 0 to 11, but it displays 1 to 12 as its value in the UI. This is to keep it consistent with the JDK Begin changeand SDK.End change
int R, W, B, E The system's current month. integer from 1 to 12
day The day. int R, W, B, E The system's current day. valid day
hour The hour int R, W, B, E The system's current hour. valid hour
minute The minute int R, W, B, E The system's current minute. valid minute
second The second int R, W, B, E The system's current second. valid second
formatString The user-defined pattern string for formatting and parsing date and time. String R, W, B "dd-MMM-yy h:mm:ss a" FULL - "EEEE,MMMM d,yyyy h:mm:ss 'o'clock' a z"
LONG - "MMMM d,yyyy h:mm:ss a z"
MEDIUM - "dd-MMM-yy h:mm:ss a"
SHORT - "M/d/yy h:mm a"
formattingStyle The ID of the format string.
Note:This property is the same as the formatString property. However, to keep compatible with Begin changea legacy API,End change it cannot be eliminated. Therefore, it is a hidden property and can only be manipulated by the set/get methods.
int R, W, B, H 2 0 - FULL
1 - LONG
2 - MEDIUM
3 - SHORT
caretPos The caret position representing the current field to be changed. It can be one of YEAR, MONTH, DATE, HOUR, MINUTE, and SECOND.
Note:The "caretPos" property of CalendarSpinner is not similar to the caret position defined in the TextField. Therefore, when you manipulate CalendarSpinner, the caret position displayed in the input field may not be consistent with the value of the caret position displayed in the property sheet.
int R, W, B 0 0 - YEAR
1 - MONTH
2 - DATE
3 - HOUR
4 - MINUTE
5 - SECOND
datePartValue The date value in long. long R, W, B, E The current system date. minimum<datePartValue <maximum
timePartValue The time value in long. long R, W, B, E The current system time. minimum<timePartValue <maximum
calendar The calendar value java.util.Calendar R, W, B The current system calendar. any instance of Calendar
value The calendar value in long. long R, W, B, E The current system calendar in long. minimum<value<maximum
maximum The maximum value. java.util.Calendar R, W, B 12/31/2050 11:59:59 PM maximum>minimum
minimum The minimum value. java.util.Calendar R, W, B 01/01/1950 12:00:00 AM any instance of Calendar
dateString The date and time shown in the entry field. String R, W, B, E The current system date. the instance of date string
date The current date and time. java.util.Date R, W, B, H The current system date and time. any instance of Date
* R = read, W = write, B = bound,E =expert, H = hidden

Events

The CalendarSpinner fires the DateChangedEvent. The listener method for this event is dateChanged(com.ibm.spinner.DateChangedEvent)

User interface

This section shows what the CalendarSpinner bean looks like and how to use it at runtime.

The currently selected value is displayed in an input field. The following picture shows what this may look like:

You can change the date or time value by clicking on different sub fields within the input field and using the arrow buttons to spin them. Or you can set the values by typing a date or time string into the input field. If the input is invalid, the CalendarSpinner restores the previous value after you press the "Enter" or "Tab" key or when you change the focus to another component.

SHORT Style Screen

The SHORT Style CalendarSpinner Bean is shown below. This bean appears when you set the "formatString" property to "SHORT".

The short style includes six sub fields:

The first five sub fields show digital values and can be changed by either by scrolling or by inputting a digital value. The AM/PM subfield can only be changed by scrolling.

MEDIUM Style Screen

The MEDIUM Style CalendarSpinner Bean is shown below. This bean appears when you set the "formatString" property to "MEDIUM".

The medium style includes seven sub fields:

The "day", "year", "hour", "minute", and "second" values can be changed either by scrolling or by inputting a digital value. The "month" and "PM_AM" values can only be changed by scrolling.

LONG Style Screen

The LONG Style CalendarSpinner Bean is shown below. This bean appears when you set the "formatString" property to "LONG".

The long style includes eight sub fields.

The "day", "year", "hour", "minute", and "second" values can be changed either by scrolling or by inputting a digital value. The "month", "PM_AM", and "time zone" values can be changed only by scrolling.

FULL Style Screen

The FULL Style CalendarSpinner Bean is shown below. This bean appears when you set the "formatString" property to "FULL".

The full style includes nine sub fields.

The "day", "year", "hour", "minute", and "second" values can be changed either by scrolling or by inputting a digital value. The "day of week", "month", "PM_AM" and "time zone" values can only be changed by scrolling.