java
有什么方法可以得到SinnerDateModel中的Day,month,year比如spinnerdatemodel(一月 15,2012),我想得到它的数据一月 15 和2012,请帮帮忙
import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerDateModel; import javax.swing.SpinnerModel; public class SpinnerDateSample { public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerDateModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("Dates/Date"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.CENTER); frame.setSize(200, 90); frame.setVisible(true); } }
JSpinner time = new JSpinner(new SpinnerDateModel()); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(time, "dd:MM:yy"); time.setEditor(dateEditor);