-5

I Have a issue to Change the json date format which i am getting as response to dd-MMM-yyyy

 //json response which i am getting in "mmm-dd-yyyy"
    String jsondate = map.get("endDate");

    Calendar c = Calendar.getInstance();

 //date format which i need the output
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");

 //the json response which i need to set in "dd-mm-yyyy"
    viewHolder.end_date.setText(dateFormat.format(c.getTime()));
Gary
  • 13
  • 3

2 Answers2

0
String createdate = 
     new SimpleDateFormat("dd-MM-yyyy").format(
            new SimpleDateFormat("yyyy-MM-dd").parse (yourDate);
holder.date.setText(createdate);
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
M.Yogeshwaran
  • 1,419
  • 4
  • 22
  • 48
0

Using SimpleDateFormat

try {
            DateFormat originalFormat = new SimpleDateFormat("dd-mm-yyyy", Locale.ENGLISH);
            DateFormat targetFormat = new SimpleDateFormat("dd-MMM-yyyy");
            Date date = originalFormat.parse("21-12-2016");
            String formattedDate = targetFormat.format(date);
        } catch (ParseException e) {

        }
RoShan Shan
  • 2,924
  • 1
  • 18
  • 38