B4J Question Date control going out of control

Jeanc161

Member
Licensed User
Longtime User
Hi
I have an app in B4J that use the datepicker control from the designer and this is the error it returned whenever i try to set a new date by code for the datepicker contol.
The source of the date is stored in a file using ticks values, but before anything i set the date on both controls 1 for the datefrom and 1 for the date to
Ex dateFrom.dateticks is set to current date - 30days and the dateto.dateTicks is set to datetime.now and this is without any call to my main sub that set theses controls
i just set the datefrom to the today date minus 30 days and thats it.
As soon has i do that this error popup and stop the processing of the display that contains the form so there is nothing that display on the form

And the funny thing is i reload the same thing right after by clicking on the button that call the main form and everything is displayed correctly without any errors.

I don't know if it is a bug in the library but it seem to do that for no reasons and since it is a library, i can't find the code that does this and neither the reason for it as it only display the error and it did not stop the execution of the other part of the codes.

Anybody have any idea on how to solve this, it is very frustrating as it got me stuck in my app.

Thanks if someone need more explication or code samples i can provide some but unable to make a very small sample since it is part of a bigger coding.

PS When i try to run the app the very first time it did not do any of this. Maybe it store it's own values somewhere to remember the last selected date, but can't seem to find that file..

Please Please any help would be really appreciated.

ERROR IN LOG DISPLAY

WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: ClockHourOfAmPm
at java.base/java.time.LocalDate.get0(LocalDate.java:709)
at java.base/java.time.LocalDate.getLong(LocalDate.java:688)
at java.base/java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:308)
at java.base/java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2704)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2343)
at java.base/java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1847)
at java.base/java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1821)
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:1207)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
at javafx.graphics/javafx.scene.Scene.doLayoutPass(Scene.java:576)
at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2510)
at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:412)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:411)
at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:438)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:563)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:543)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:536)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:342)
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:832)
 

stevel05

Expert
Licensed User
Longtime User
Have you set the date format? If so, what have you used?
 
Upvote 0

roerGarcia

Active Member
Licensed User
Longtime User
From here
Exception in thread "main" java.time.format.DateTimeParseException:
Text '2019-03-18 13-14-48' could not be parsed:
Invalid value for ClockHourOfAmPm (valid values 1 - 12): 13

at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
at test1.FirstClass.main(FirstClass.java:20)

Check the value.
 
Upvote 0

Jeanc161

Member
Licensed User
Longtime User
From here
Exception in thread "main" java.time.format.DateTimeParseException:
Text '2019-03-18 13-14-48' could not be parsed:
Invalid value for ClockHourOfAmPm (valid values 1 - 12): 13

at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
at test1.FirstClass.main(FirstClass.java:20)

Check the value.
I check the value but the thing is it get that error as soon as i load the layout that contains these controls, and i can't go any further, cause it stop the execution of loading the rest of the controls in the screen, and the layout get not loaded. i wonder if there is something wrong when settings the properptys when it load the layout cause the error that i got is this one
java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: ClockHourOfAmPm
it said Unsuported field ClockHourOfAmPm.

I also set the date format to include the hh:mm:ss before loading the layout into view, but to no avail, stiil got the same error the first i load the layout and after that evething is loaded correctly the second time.
I even try to load it with no data to be applied to it on loading, maybe i should need a little delay so the controls might take a little bit of time to load before the controls get set by the code values.
That's about the only thing left that i did not try cause it's a bit complicated to do that, load the layout and wait for maybe 250ms to continue the code that set up the other stuff in the program or sub.
Sometimes java will take a little longer to set certains property, it append to me with the webview wich i have to delay to about 300ms before loading anything in that webview. So the guess is open, i don't really know anymore what to test or change so that damn error will go away the first time it is loaded.

Any guess anyone...
 
Upvote 0

roerGarcia

Active Member
Licensed User
Longtime User
Change that to the date january, 1, 2022. And test. I had a "deja vu"

Ex dateFrom.dateticks is set to current date - 30days and the dateto.dateTicks is set to datetime.now and this is without any call to my main sub that set theses controls
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Also..

13-14-48 is not format hh:mm:ss (hh is 12 hour clock, separator in not ":")
Try DateTime.TimeFormat = "HH-mm-ss"
 
Upvote 0

Jeanc161

Member
Licensed User
Longtime User
Can we have that library in the class source code available somewhere i will like to try something to fix this problem.
I realy need this datepicker stuff but it is not operational the way it is right now cause of all the errors it trow up everytime it loads the first time
I tried something else this morning, load the layout that contains the controls, and right a way set the datePicker.DateTicks to dateTime.now
and still get the same bullshit from that control, so i think there is a problem in the library.

If someone knows where to get the library source code, i will realy appreciate the link so i can try to run it as a class and see where the problem is and to fix it once and for all.

Thanks.
 
Upvote 0

Jeanc161

Member
Licensed User
Longtime User
Change that to the date january, 1, 2022. And test. I had a "deja vu"

Ex dateFrom.dateticks is set to current date - 30days and the dateto.dateTicks is set to datetime.now and this is without any call to my main sub that set theses controls
The problem is that i can't set the value, it crash when i load the layout that contains the controls and stop the execution of loading the rest of the layout, unless you know a way to set a value before it is loaded i don't see how to do that.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Based on the error report "2019-03-18 13-14-48" can not be parsed.

Before loading layout do this


B4X:
    DateTime.DateFormat = "yyyy-MM-dd"
    DateTime.TimeFormat = "HH-mm-ss"
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You have not posted your code that shows how you are setting up the Date control. Things will go quicker if you do.

If should be something like:

B4X:
DatePicker1.DateFormat = "dd/MM/yyyy"
    DatePicker2.DateFormat = "dd/MM/yyyy"

Depending on how you want it displayed. Note: MM for month not mm. And no time format specified as the control doesn't support time.
 
Last edited:
Upvote 0

Jeanc161

Member
Licensed User
Longtime User
Based on the error report "2019-03-18 13-14-48" can not be parsed.

Before loading layout do this


B4X:
    DateTime.DateFormat = "yyyy-MM-dd"
    DateTime.TimeFormat = "HH-mm-ss"
Congrats man you solve the puzzle, adding the dateTime.timeformat = "hh:mm:ss" solve that crissis, i did just that before loading the layout i set the date and time format, i only initialize the date before but not the time, doing both solve the mystery, i no longer have any error while loading the layout

Problem solve thanks all for your suggestion and your help, We did it...
 
Upvote 0
Top