javaswingdatejcalendar

How to get month name in string on JMonthChooser from JCalendar


How to get month name in string on JMonthChooser from JCalendar (toedter.com/jcalendar/) and convert it to string "01", "02","03",...,"12" as simple as using SimpleDateFormat.

I'll try :

String mymonth;
SimpleDateFormat sdfm = new SimpleDateFormat("MM");
JComboBox combom = (JComboBox)jMonthChooser1.getSpinner();
mymonth = sdfm.format(((JTextField)combom.getEditor()).getText());

But no success


Solution

  • I got the other way that what I need : Here are the code :

    JCalendar jCalendar1 = new JCalendar();
    String mymonth;
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM");
    Date date1 = jCalendar1.getDate();
    mymonth = sdf1.format(date1);