I want to use a JSpinner to select a time for a countdown timer where the user selects the HR,MIN,SEC where any of these values can be 00
. I was using the SpinnerDateModel
but the HR cannot be set to 00
Asked
Active
Viewed 380 times
0

Boann
- 48,794
- 16
- 117
- 146

user3922757
- 305
- 2
- 5
- 14
-
Have you considered using three separate spinners – MadProgrammer Nov 28 '14 at 19:55
-
I probably will if I can't come up with a better alternative. – user3922757 Nov 28 '14 at 19:58
1 Answers
1
The default format of date display by the JSpinner is locale-dependent, but you can customize the date formatting by explicitly setting a JSpinner.DateEditor instance with your desired format as the spinner's editor component:
JSpinner spinner = new JSpinner(new SpinnerDateModel());
spinner.setEditor(new JSpinner.DateEditor(spinner, "HH:mm:ss"));
The HH
there will ensure the hour is displayed with leading zeros.

Boann
- 48,794
- 16
- 117
- 146