Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class DateTime

extends Composite
Class Inheritance
Imports
java.text.*, java.text.AttributedCharacterIterator.*, java.text.DateFormat.*, java.util.*, org.eclipse.swt.*, org.eclipse.swt.accessibility.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class are selectable user interface objects that allow the user to enter and modify date or time values.

Note that although this class is a subclass of Composite, it does not make sense to add children to it, or set a layout on it.

Styles:
DATE, TIME, CALENDAR, SHORT, MEDIUM, LONG, DROP_DOWN, CALENDAR_WEEKNUMBERS
Events:
DefaultSelection, Selection

Note

Only one of the styles DATE, TIME, or CALENDAR may be specified, and only one of the styles SHORT, MEDIUM, or LONG may be specified. The DROP_DOWN style is only valid with the DATE style.

Important Note

This class is not intended to be subclassed.

Since
3.3
See Also
DateTime snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv Color
pack-priv Calendar
pack-priv long
calendarHandle

Major handles of this class.

pack-priv long
containerHandle

Major handles of this class.

pack-priv FieldPosition
private DateFormat
pack-priv int
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv Button
pack-priv long
editableHandle

GTK4 field used to hold the main GtkEditable widget.

pack-priv Color
pack-priv boolean
pack-priv boolean
pack-priv int
pack-priv Locale
pack-priv static final int
private int
private int
pack-priv static final int
pack-priv int
pack-priv int
pack-priv Listener
mouseEventListener

Used when SWT.DROP_DOWN is set

pack-priv DateTime
pack-priv Listener
pack-priv Listener
pack-priv Shell
pack-priv Point
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv static final int
pack-priv long
spinButtonHandle

Major handles of this class.

pack-priv long
textEntryHandle

Major handles of this class.

pack-priv StringBuilder
pack-priv int
pack-priv int
Inherited from org.eclipse.swt.widgets.Composite:
backgroundModechildrenLoweredembeddedHandlefixClipHandlefixClipMapimHandlelayoutlayoutCountNO_INPUT_METHODnoChildDrawingpopupChildsocketHandletabList

Constructor Summary

AccessConstructor and Description
public
DateTime(Composite
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
public void
addSelectionListener(SelectionListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

private int
calculateCalendarXpos(Point calendarSize, Rectangle coordsRelativeToScreen, Rectangle displayRect, int width)

private int
calculateCalendarYpos(Point containerBounds, Rectangle coordsRelativeToScreen, int height, Rectangle displayRect)

pack-priv static int
protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

Checks that this class can be subclassed.
pack-priv boolean
pack-priv void
pack-priv Point

Returns:

text entry size to hold the longest possible formatted text.
computeMaxTextSize
(int wHint, int hHint, boolean changed)

Compute the native text entry size when the formatted text inside the entry is at the longest length possible.

pack-priv Point
computeSizeInPixels(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Composite.computeSizeInPixels.

pack-priv Rectangle
computeTrimInPixels(int x, int y, int width, int height)

Overrides org.eclipse.swt.widgets.Scrollable.computeTrimInPixels.

pack-priv void
pack-priv void
private void
private void
private void
pack-priv void
createPopupShell(int year, int month, int day)

private void
pack-priv void
pack-priv void
private long
pack-priv GdkRGBA
pack-priv void
pack-priv long
private void
pack-priv long
pack-priv long
pack-priv int
getArrow(long widget)

private static int

Returns:

the Calendar field or -1 if this is not a valid Fieldposition
getCalendarField
(FieldPosition fieldPosition)

Extracts the calendarfield for the given fieldposition

private static int

Returns:

the calendarfield coresponding to the Field
getCalendarField
(DateFormat.Field field)

Extracts the calendarfield transforming HOUR1 types to HOUR0

pack-priv String
pack-priv void
public int

Returns:

a positive integer beginning with 1
getDay
()

Returns the receiver's date, or day of the month.

private static FieldPosition

Returns:

a new FieldPosition
getFieldPosition
(AttributedCharacterIterator
the iterator to use
iterator
)

Searches the current postion of the iterator for a Field and constructs a FieldPosition from it

private static FieldPosition

Returns:

a FieldPosition init to this Field and begin/end index
getFieldPosition
(DateFormat.Field
the field to use
field
,
AttributedCharacterIterator
the iterator to extract the data from
iterator
)

creates a FieldPosition out of a Field and and a AttributedCharacterIterators current position

pack-priv DateFormat
getFormat(Locale locale, int style)

pack-priv String
pack-priv GtkBorder

Returns:

GtkBorder object that holds the padding values.
getGtkBorderPadding
()

Gets the border padding structure, which can be used to determine the inner padding of the text field.

public int

Returns:

an integer between 0 and 23
getHours
()

Returns the receiver's hours.

public int

Returns:

an integer between 0 and 59
getMinutes
()

Returns the receiver's minutes.

public int

Returns:

an integer between 0 and 11
getMonth
()

Returns the receiver's month.

pack-priv String
private FieldPosition

Returns:

the next FieldPosition
getNextField
(FieldPosition
the Field to start from
field
)

Given a FieldPosition searches the next field in the format string

private FieldPosition

Returns:

the next field of the given one
getPreviousField
(FieldPosition field)

public int

Returns:

an integer between 0 and 59
getSeconds
()

Returns the receiver's seconds.

pack-priv String
pack-priv String

Returns:

Spinner's text
getText
()

Returns a string containing a copy of the contents of the receiver's text field, or an empty string if there are no contents.

pack-priv String

Returns:

substring of str between start & end. If start & end indices are malformed, an empty string is returned.
getText
(String str, int start, int end)

Gets the substring between start and end indices of the caller provided string.

pack-priv String
getText(int start, int end)

pack-priv Point

Returns:

the highlighted (selected) text or position of cursor
getTextSelection
()

Returns the selected text.

public int

Returns:

an integer between 1752 and 9999
getYear
()

Returns the receiver's year.

pack-priv boolean
gtk4_key_press_event(long
the corresponding controller responsible for capturing the event
controller
,
int
the pressed key
keyval
,
int
raw code of the pressed key
keycode
,
int
the bitmask, representing the state of the modifier keys and pointer buttons
state
,
long
the GdkEvent captured
event
)

Overrides org.eclipse.swt.widgets.Composite.gtk4_key_press_event.

pack-priv long
pack-priv long
pack-priv long
pack-priv void
gtk_gesture_release_event(long
the corresponding controller responsible for capturing the event
gesture
,
int
how many touch/button presses happened with this one
n_press
,
double
the x coordinate, in widget allocation coordinates
x
,
double
the y coordinate, in widget allocation coordinates
y
,
long
the GdkEvent captured
event
)

Overrides org.eclipse.swt.widgets.Control.gtk_gesture_release_event.

pack-priv long
pack-priv long
pack-priv long
gtk_output(long widget)

Overrides org.eclipse.swt.widgets.Widget.gtk_output.

Output signal is called when Spinner's arrow buttons are triggered, usually by clicking the mouse on the [gtk3: +/-] buttons.
pack-priv void
handleFocus(int type)

private boolean
pack-priv void
private void
pack-priv void
private final void
private final void
private final void
pack-priv void
incrementField(int amount)

pack-priv void
private boolean
private boolean
private boolean
pack-priv boolean
private boolean
private static boolean

Returns:

true if considered the same, false otherwise
isSameField
(FieldPosition
first position to compare
p1
,
FieldPosition
second position to compare
p2
)

Check if the given FieldPosition are considdered "the same", this is when both are not null and reference the same java.text.Format.Field attribute, or both of them have no fieldattribute and have the same position

private boolean
pack-priv boolean
isValidDate(int year, int month, int day)

pack-priv boolean
isValidTime(int fieldName, int value)

private char
keyToString(int key)

pack-priv void
pack-priv boolean
pack-priv void
pack-priv void
pack-priv void
private void
pack-priv void
pack-priv void
public void
removeSelectionListener(SelectionListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the control is selected by the user.

pack-priv void
pack-priv void
pack-priv void
selectField(DateFormat.Field field)

selects the first occurrence of the given field

pack-priv void
selectField(FieldPosition fieldPosition)

Selects the given field at the given start/end coordinates

pack-priv void
public void
setBackground(Color
the new color (or null)
color
)

Overrides org.eclipse.swt.widgets.Control.setBackground.

Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
pack-priv void
pack-priv void
pack-priv void
setBoundsInPixels(int x, int y, int width, int height)

Overrides org.eclipse.swt.widgets.Control.setBoundsInPixels.

private void
public void
setDate(int
an integer between 1752 and 9999
year
,
int
an integer between 0 and 11
month
,
int
a positive integer beginning with 1
day
)

Sets the receiver's year, month, and day in a single operation.

public void
setDay(int
a positive integer beginning with 1
day
)

Sets the receiver's date, or day of the month, to the specified day.

private void
setDropDownButtonSize()

Usually called when control is resized or first initialized.

public void
setEnabled(boolean
the new enabled state
enabled
)

Overrides org.eclipse.swt.widgets.Control.setEnabled.

Enables the receiver if the argument is true, and disables it otherwise.
pack-priv void
public void
setFont(Font
the new font (or null)
font
)

Overrides org.eclipse.swt.widgets.Control.setFont.

Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
pack-priv void
public void
setForeground(Color
the new color (or null)
color
)

Overrides org.eclipse.swt.widgets.Control.setForeground.

Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
pack-priv void
public void
setHours(int
an integer between 0 and 23
hours
)

Sets the receiver's hours.

public void
setMenu(Menu
the new pop up menu
menu
)

Overrides org.eclipse.swt.widgets.Control.setMenu.

Sets the receiver's pop up menu to the argument.
public void
setMinutes(int
an integer between 0 and 59
minutes
)

Sets the receiver's minutes.

public void
setMonth(int
an integer between 0 and 11
month
)

Sets the receiver's month.

public void
setSeconds(int
an integer between 0 and 59
seconds
)

Sets the receiver's seconds.

pack-priv void
setText(String dateTimeText)

Calculates appropriate width of GtkEntry and adds Date/Time string to the Date/Time Spinner

pack-priv void
setTextField(FieldPosition field, int value)

pack-priv void
setTextSelection(int start, int end)

Highlight (select) the text between the start and end.

public void
setTime(int
an integer between 0 and 23
hours
,
int
an integer between 0 and 59
minutes
,
int
an integer between 0 and 59
seconds
)

Sets the receiver's hours, minutes, and seconds in a single operation.

public void
setYear(int
an integer between 1752 and 9999
year
)

Sets the receiver's year.

private void
showPopupShell(Point containerBounds, Point calendarSize, Rectangle coordsRelativeToScreen, Rectangle displayRect)

private boolean
pack-priv void
private FieldPosition
updateField(FieldPosition field)

Returns a field with updated positionla data

private int
Inherited from org.eclipse.swt.widgets.Composite:
_getChildren_getTabListadjustChildClippingapplyThemeBackgroundchangedcheckBufferedcomputeTabListconnectFixedHandleDrawcreateHandledrawBackgrounddrawBackgroundInPixelsenableWidgetfindDeferredControlfindMenusfixChildrenfixClippingsfixModalfixParentGdkResourcefixStylefixTabListfixZOrderforceFocusgetBackgroundModegetChildrengetChildrenCountgetClientAreaInPixelsgetLayoutgetLayoutDeferredgetTabListgtk_button_press_eventgtk_drawgtk_focusgtk_focus_in_eventgtk_focus_out_eventgtk_mapgtk_realizegtk_scroll_childgtk_style_updatedhasBorderhooksKeysimHandleisLayoutDeferredisTabGrouplayoutlayoutlayoutlayoutlayoutmarkLayoutminimumSizemoveAbovemoveBelowmoveChildrenmustBeVisibleOnInitBoundsparentingHandleprintWidgetpropagateDrawredrawChildrenreleaseChildrenreleaseHandleremoveControlresizeHandlereskinChildrensetBackgroundModesetBoundssetFocussetLayoutsetLayoutDeferredsetOrientationsetScrollBarVisiblesetTabGroupFocussetTabItemFocussetTabListshowWidgettoStringtranslateMnemonictranslateTraversaltraversalCodeupdateBackgroundModeupdateLayout