B4J Question strange error

madru

Active Member
Licensed User
Longtime User
Hi,

not really sure how I should explain my problem as I can not share the code, lets try....


the app fetches data from a DB and fills a Tableview (not B4XTable) with data in the main form, part of the data are datetime fields from the DB
a 2nd Form holds only a datepicker

the form with the datepicker
B4X:
Sub Class_Globals
    Private fx As JFX
    Private xui As XUI
    Private frm As Form
    Private jrdc As jRDC2
    Private dpIntervalDone As DatePicker
End Sub


Public Sub Initialize (Parent As Form,left As String,top As String,width As String,height As String,titel As String,action As Int)
    If frm.IsInitialized = False Then
        frm.Initialize("frm", 800, 600)
        frm.RootPane.LoadLayout("frmVacation")
        
    End If
          
    Dim ps As Screen = fx.PrimaryScreen
    frm.WindowWidth = width
    frm.WindowHeight = height
    frm.WindowTop = ps.MinY +  (ps.MaxY - frm.WindowHeight) / 2
    frm.WindowLeft = ps.MinX + (ps.MaxX - frm.WindowWidth) / 2
    
    frm.Title=titel
    frm.SetFormStyle("DECORATED")
    frm.Resizable = False

'    frm.SetOwner(Parent)
    jrdc.Initialize
    

End Sub

Public Sub Show' As Paint
    frm.ShowAndWait
    'The next line will only be executed after the form is closed.
End Sub

showing the form is done here
B4X:
            Dim v1 As Vacation
            v1.Initialize(MainForm,(MainForm.WindowLeft+15),(MainForm.windowTop+ 50),(800),(700),"Vacation",0)
            v1.Show

this works as expected the Form does open and the date picker is usable..... BUT

changing the datetime field in the Mainform to a different format like:
B4X:
DateTime.DateFormat = "dd.MM.yy HH:mm"

breaks the App, launching the Form with the datepicker ends with this:

Waiting for debugger to connect...
Program started.

Error occurred on line: 35 (vacation) ====> frm.ShowAndWait
java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay
at java.base/java.time.LocalDate.get0(LocalDate.java:708)
at java.base/java.time.LocalDate.getLong(LocalDate.java:687)
at java.base/java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:308)
at java.base/java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2696)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2335)
at java.base/java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1843)
at java.base/java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1817)
at javafx.base/javafx.util.converter.LocalDateTimeStringConverter$LdtConverter.toString(LocalDateTimeStringConverter.java:240)
at javafx.base/javafx.util.converter.LocalDateStringConverter.toString(LocalDateStringConverter.java:139)
at javafx.base/javafx.util.converter.LocalDateStringConverter.toString(LocalDateStringConverter.java:45)
at javafx.controls/javafx.scene.control.skin.ComboBoxPopupControl.updateDisplayNode(ComboBoxPopupControl.java:337)
at javafx.controls/javafx.scene.control.skin.DatePickerSkin.getDisplayNode(DatePickerSkin.java:216)
at javafx.controls/javafx.scene.control.skin.ComboBoxBaseSkin.updateDisplayArea(ComboBoxBaseSkin.java:289)
at javafx.controls/javafx.scene.control.skin.ComboBoxBaseSkin.layoutChildren(ComboBoxBaseSkin.java:167)
at javafx.controls/javafx.scene.control.Control.layoutChildren(Control.java:601)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1204)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
at javafx.graphics/javafx.scene.Scene.doLayoutPass(Scene.java:576)
at javafx.graphics/javafx.scene.Scene.preferredSize(Scene.java:1748)
at javafx.graphics/javafx.scene.Scene$2.preferredSize(Scene.java:393)
at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66)
at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1086)
at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
at javafx.graphics/javafx.stage.Window.show(Window.java:1189)
at javafx.graphics/javafx.stage.Stage.show(Stage.java:273)
at javafx.graphics/javafx.stage.Stage.showAndWait(Stage.java:463)
at anywheresoftware.b4j.objects.Form.ShowAndWait(Form.java:231)
at b4j.example.vacation._show(vacation.java:106)
at b4j.example.main$ResumableSub_MenuBar1_Action.resume(main.java:4012)
at b4j.example.main._menubar1_action(main.java:3318)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:234)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)



i have no idea whats going on, both form are complete separated ......


any help is appreciated
 

madru

Active Member
Licensed User
Longtime User
I don't recommend using Form.ShowAndWait. Modal dialogs are bad.

Looks like the error happens when a ComboBox tries to redraw the items.
I am actually rewriting the App to use B4XPages, but how is this redraw error related to the date format - i really don’t understand.
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
Erel, there is no Combobox in the project.....

skeleton to show the problem attached
 

Attachments

  • error_datetime.zip
    3.6 KB · Views: 98
Upvote 0

madru

Active Member
Licensed User
Longtime User
I really don't get it :(

if I do this in AppStart
B4X:
Dim t As Long = 1651399607000
DateTime.DateFormat = "dd.MM.yy HH:mm"
Log(DateTime.Date(t))
I get the 01.05.22 12:06 in log

why is this related to the date picker in a different Form where not even a reference is set?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The date picker uses the format you've set for the app unless you specifically override it on the date picker.
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
looks like I am too stu..., can somebody make the example from Post 5 working?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you want a different format in the rest of the app you can set the date format directly on the date picker after the loadlayout.

B4X:
DatePicker1.DateFormat = "dd.MM.yy"
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
oh, boy - no comment :(

The Man Who Does Not Read Has No Advantage Over the Man Who Cannot Read​


THX
 
Upvote 0
Top