在数据库中存的有 生日 datetime类型的 例如:1988-03-11 00:00:00:00,让在swing中如何显示出来为 1988-03-11并且在JComboBox显示,在瑞年的时候2月分只有29天,其他年份有28天,1,3,5,7,8,10,12月有31天,4,6,9,10,11月有30天
谢谢各位

解决方案 »

  1.   

           public String getTime(){
      SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      String time = sdf1.format(new Date());
      return time;
    }//new Date()-系统当前时间

    public String getDay(){
      SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
      String day = sdf1.format(new Date());
      return day;
    }
      

  2.   

    public class DateSpinner extends JSpinner{
            public DateSpinner(String formatText) {
                SpinnerDateModel model = new SpinnerDateModel();
                this.setModel(model);            DateEditor editor = new DateEditor(this,formatText);
                JTextField field = editor.getTextField();
                field.setHorizontalAlignment(field.CENTER);
                field.setFont(font);
                this.setEditor(editor);            setOpaque(true);
                updateUI();
            }
        }