Converting yyyy-mm-dd into dd mm yyyy

See the first problem is that you are using different delimiters for String and Date. So either you do "2013-06-24" to "2013 06 24" in String or do new SimpleDateFormat("dd MMM yyyy") to new SimpleDateFormat("dd-MMM-yyyy").

And second problem is that you cannot directly change format like this, in String you are having year-month-date format, so first make a Date object with same format than change it to your desired format as below :

date1="2013-06-24";

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

Date dt = format.parse(date1);

SimpleDateFormat your_format = new SimpleDateFormat("dd-MMM-yyyy");

date2 = your_format.format(dt);

Change

SimpleDateFormat d= new SimpleDateFormat("dd MMM yyyy");

with

SimpleDateFormat d= new SimpleDateFormat("yyyy-MM-dd");

you have to follow the date1 pattern. Then you can format your parsed date with

new SimpleDateFormat("dd MMM yyyy");

public String getStringFormatted(String datestring) {
    String format = "dd MM yyyy";
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.getDefault());
    return sdf.format(new Date(datestring.replaceAll("-", "/")));
}

You need two DateFormat instances: One to parse the original String, and another to output the one you want.

DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
DateFormat outputFormat = new SimpleDateFormat("dd MMM yyyy");
String inputDateStr="2013-06-24";
Date date = inputFormat.parse(inputDateStr);
String outputDateStr = outputFormat.format(date);