-2

I want to convert this date but parse exemption it should be like this result "2019-12-28 14:00:00"

 try {
        String strCurrentDate = "April 08 2020 4:24 AM"
        SimpleDateFormat format = new SimpleDateFormat("MMM dd yyyy  hh:mm a");
        Date newDate = format.parse(strCurrentDate);
        format = new SimpleDateFormat("MMM dd,yyyy hh:mm a");
        String date = format.format(newDate);

        Log.d("datessscc", date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
Allen Oculam
  • 51
  • 1
  • 9

1 Answers1

-1

Please change your SimpleDateFormat

Try This:

 SimpleDateFormat input = new SimpleDateFormat("MMM dd yyyy hh:mm a");
    SimpleDateFormat output = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        Date getAbbreviate=input.parse("May 22 2020 4:22 AM");    // parse input
        Log.i("ouput_Date", "onCreate: "+output.format(getAbbreviate));    // format output
        String date=output.format(getAbbreviate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
Android Geek
  • 8,956
  • 2
  • 21
  • 35