Issue
I'd like to have a datepicker utilizing either JavaFX's standard library, or the JFoenix library that allows you to pick your day of the year. Rather than when viewing February, and being able to pick the day of the month, I'd like those days to show up as days of the year. So for February 14, it would show 45 where you would normally see 14. Currently I have it where once selected the label by the datepicker will show the date of the year but the user will have to keep guessing until they have gotten the right date. I also don't think using the tooltip to show the day of year would be useful. Any suggestions on how to accomplish this?
Thank you
Solution
You could use a custom dateCellFactory
for this purpose returning cells with overridden updateItem
methods:
DatePicker picker = new DatePicker();
picker.setDayCellFactory(p -> new DateCell() {
@Override
public void updateItem(LocalDate item, boolean empty) {
super.updateItem(item, empty);
if (item == null) {
setText("");
} else {
setText(Integer.toString(item.getDayOfYear()));
}
}
});
Answered By - fabian