-1

i want to format this type of date : Sun Feb 14 12:12:47 GMT+05:30 2016

into SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);

this is what i tried:

try {

SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z yyyy",
        Locale.ENGLISH);

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);



Date pasta = sdf.parse(notesTimeStampArray.get(i));

String  newDate =  pasta.toString();

Date past = format.parse(newDate);


Date now = new Date();

Toast.makeText(TabFragment2.context, "inside 1 success", Toast.LENGTH_SHORT).show();

}catch (Exception e){


Toast.makeText(TabFragment2.context, "error : " +e.getMessage(), Toast.LENGTH_SHORT).show();

}

but am not succeeding, anyone can correct me ? it'll so helpful for me

remy boys
  • 2,928
  • 5
  • 36
  • 65

1 Answers1

2

Use format instead of parse to format the date returned from the first date format operation

String dateString = format.format(pasta);
Reimeus
  • 158,255
  • 15
  • 216
  • 276