Java tutorial
import java.awt.BorderLayout; import java.util.Calendar; import java.util.Date; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerDateModel; import javax.swing.SpinnerModel; public class SpinnerDateStartEndSample { public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Calendar cal = Calendar.getInstance(); Date now = cal.getTime(); cal.add(Calendar.YEAR, -50); Date startDate = cal.getTime(); cal.add(Calendar.YEAR, 100); Date endDate = cal.getTime(); SpinnerModel model = new SpinnerDateModel(now, startDate, endDate, Calendar.YEAR); JSpinner spinner1 = new JSpinner(model); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); } }