How to set value of JSpinner to a certain date

前端 未结 1 1568
独厮守ぢ
独厮守ぢ 2021-01-26 15:07

I have a JSpinner which I add to the JPanel I would like to set its time to the :GregorianCalendar calendar

JSpinner spin         


        
相关标签:
1条回答
  • 2021-01-26 15:38

    One should do:

            SpinnerDateModel model = new SpinnerDateModel();
            model.setCalendarField(Calendar.DAY_OF_YEAR);
    
            JSpinner spinner = new JSpinner();
            spinner.setModel(model);
    
            SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
            java.sql.Time time = new java.sql.Time(osoba.getDataZatrudnienia().getTime().getTime());
            spinner.setValue(time);
    
    0 讨论(0)
提交回复
热议问题