Reputation: 305
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
Upvotes: 0
Views: 386
Reputation: 50041
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.
Upvotes: 1