How to show only date on JSpinner

2.5k views Asked by At

I have a JSpinner I would like to show only date(without time) in it.

This is what I do:

SpinnerDateModel model = new SpinnerDateModel();
model.setCalendarField(Calendar.DAY_OF_YEAR);
dataRozpoczeciaSpinner = new JSpinner();
dataRozpoczeciaSpinner.setModel(model);

but the time is also displayed: 27.05.68 00:00

1

There are 1 answers

0
Anto On

Just try the following:

SimpleDateFormat model = new SimpleDateFormat("dd.MM.yy");
dataRozpoczeciaSpinner = new JSpinner(new SpinnerDateModel());
dataRozpoczeciaSpinner.setEditor(new JSpinner.DateEditor(dataRozpoczeciaSpinner, model.toPattern()));