ParseException: Unparseable date: "Wed Mar 30 00:00:00 GMT+05:30 2016" (at offset 4)

Ryan Aluvihare picture Ryan Aluvihare · Mar 30, 2016 · Viewed 19.5k times · Source

Im trying parse a String with a date to convert it into a Date format. Strings are in the following format.

Wed Mar 30 00:00:00 GMT+05:30 2016

But when im parsing the String i get a error saying,

java.text.ParseException: Unparseable date: "Wed Mar 30 00:00:00 GMT+05:30 2016" (at offset 4)

below is a part of my code. How do i avoid this error? Any help would be appreciated.

SimpleDateFormat sdf3 = new SimpleDateFormat("EEE MM dd kk:mm:ss zzzz yyyy",Locale.ENGLISH);

for(int i=0 ; i <jArr.length() ; i++){
    String tempDate = jArr.get(i).toString();
    dateList.add(tempDate);
}

try{
    Date d1 = sdf3.parse(dateList.get(0));                        

}catch (Exception e){ e.printStackTrace(); }

Answer

Satya siva prasad picture Satya siva prasad · Mar 30, 2016

Check this once. working fine for me

SimpleDateFormat sdf3 = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);

    Date d1 = null;
    try{
        d1 = sdf3.parse("Wed Mar 30 00:00:00 GMT+05:30 2016");

    }catch (Exception e){ e.printStackTrace(); }


    System.out.println("check..." + d1);