edvin / tornadofx-controls

CSS Stylable Controls for JavaFX
Apache License 2.0
107 stars 16 forks source link

DateTimePicker picker control for time #8

Open DJViking opened 7 years ago

DJViking commented 7 years ago

The DateTimePicker does not have a TimePicker, just a DatePicker. The button opens the same calendar as the DatePicker.

edvin commented 7 years ago

That's right, it currently only allows you to pick the date and you have to write the time yourself. I did it like this because it's more convenient IMO. Picking the time just takes more time (pun intented), but for date you might need to consult a calendar. There is only one button, so this shouldn't be confusing, but I'd be up for adding a time picker in form of two spinners perhaps, if that's what you're envisioning?

Any feedback or sketch you can provide with regards to layout suggestions are most welcome :)

DJViking commented 7 years ago

The project ControlsFX started with a TimePicker, but it did not make it. https://bitbucket.org/controlsfx/controlsfx/pull-requests/522/new-control-timepicker/diff

There is even a JDK feature request for a TimePicker. https://bugs.openjdk.java.net/browse/JDK-8090397 Java has LocalTime, LocalDate, LocalDateTime. It should definitely have JavaFX control for each of these.

The project JFoenix has a similar TimePicker implementation: https://github.com/jfoenixadmin/JFoenix timepicker

Such a similar TimePicker could be implemented as a second popup after choosing the date.

edvin commented 7 years ago

Certainly possible, but I think we're better off reimplementing the date picker to support grater freedom and control over the functionality and design. The DateTimePicker in it's current form is simply a hack around the stock DatePicker. I don't have time to look at this right now, but a PR would be most welcome :)

iameddz commented 7 years ago

I would also look forward to a TimePicker!

DJViking commented 5 years ago

The time picker could be implemented as sliders, perhaps something similar like the Android date time picker. Screenshot_20190314-203309

edvin commented 5 years ago

That design works on mobile but seems quite cumbersome to use on a desktop IMO.

owan1024 commented 3 years ago

Works fine with one small comment. Edit of the time gets lost if you re-pick the date. Think this would be solved for example by using the editor text string (or perhaps adding a commit ).

replace: time = localDateTime.toLocalTime(); with: time = LocalDateTime.parse(this.getEditor().getText(), formatter).toLocalTime();