I want to convert the org.joda.time.LocalDate object to java.util.GregorianCalendar. java.util.GregorianCalendar month displayed from index 0 to 11. So October is represented with digit 9 , November with digit 10....Whereas for LocalDate October is represented with digit 10, november with 11....
I am working on existing application where they have used GregorianCalendar. Now I want to convert my LocalDate value which I had received through a method call into GregorianCalendar format so that month values are matched.
I have already searched many blogs but could not convert the value. Below is the code I tried but still could not able to change the date format to GregorianCalendar format.
java code:
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
class Convert{
    public static String format(GregorianCalendar calendar){
        SimpleDateFormat fmt = new SimpleDateFormat("dd-M-yyyy");
        fmt.setCalendar(calendar);
        String dateFormatted = fmt.format(calendar.getTime());
        System.out.println("--date formatted--- " + dateFormatted);
        return dateFormatted;
    }
    void convertLocalDateToGregorianCalendar(){
        LocalDate localDate = new LocalDate();
        DateTime dateTimeObj = localDate.toDateTimeAtStartOfDay();
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTimeInMillis(dateTimeObj.getMillis());
        String formattedGCDate = format(gc);
        System.out.println("converted LocalDate to GregorianDate date value " + formattedGCDate);
    }
    public static void main(String[] args) {
                new Convert().convertLocalDateToGregorianCalendar();         
} }
Output:
--date formatted--- 13-10-2016
converted LocalDate to GregorianDate date value 13-10-2016
Expected date value in the output: 13-9-2016 (As for GregorianCalendar October month is represent with digit 9).
PS: java5 is the version I am using.
 
     
     
     
    