问题
How to make a time format like this hourhour:minuteminute:secondsecond,milisecondmilisecondmilisecond
using only one Jspinner when I make this spinner using visual GUI of NET beans.
回答1:
You need to use both, SpinnerDateModel
and JSpinner.DateEditor
with the correct date format pattern:
public class JSpinnerDateFormat extends JFrame {
public JSpinnerDateFormat() {
super("JSpinner Date Format");
JSpinner spinner = new JSpinner();
spinner.setModel(new SpinnerDateModel());
spinner.setEditor(new JSpinner.DateEditor(spinner, "HH:mm:ss.SSS"));
add(spinner);
pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new JSpinnerDateFormat();
}
}
来源:https://stackoverflow.com/questions/10477688/how-to-make-a-time-format-in-jspinner