The date time picker component can be used to input a date, a time or both using the DATETIMEPICKER_TYPE_TIME, DATETIMEPICKER_TYPE_DATE and DATETIMEPICKER_TYPE_DATETIME constants.
Dim mydate3 As ABMDateTimePicker Dim NewDate As Long = DateTime.Now mydate3.Initialize(page, "mydate3", ABM.DATETIMEPICKER_TYPE_DATETIME, NewDate, "Pick a date and time", "") mydate3.CancelText = "Back" mydate3.PickText = "OK" mydate3.TodayText = "Today" mydate3.Language = "en" mydate3.ReturnDateFormat = "MM/DD/YYYY" // <--- see demo source code for settings mydate3.ReturnTimeFormat = "HH:mm" // <--- see demo source code for settings mydate3.FirstDayOfWeek = 0 //mydate3.ClickThrough = True <--- set to true if, when the user makes a selection, the ok action should be triggered. page.CellR(1,1).AddComponent(mydate3)
When changed, an event will be raised: YourComp_Changed(dataMilliseconds as String). The param is a string but can easily be converted to a long and a date.
Sub mydate3_Changed(dateMilliseconds As String) // convert to a B4J date Dim BackDate As Long = dateMilliseconds DateTime.DateFormat = "MM/dd/yyyy" DateTime.TimeFormat = "HH:mm" myToastId = myToastId + 1 page.ShowToast("toast" & myToastId, "toastred", "Date/time: " & DateTime.Date(BackDate) & " " & DateTime.Time(BackDate), 5000) End Sub
You can also set or get the components date/time using SetDate(date as long) and GetDate() as long methods.