-1

I want this gmt time into YYYY-MM-DD format but i went through the procedure it give parse exception error.

I want to convert this String type of Fri Apr 08 2016 00:00:00 GMT+0530 (IST) into date format so that i can insert into my mqysql data base.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    check this url http://stackoverflow.com/questions/20159655/how-to-get-gmt-date-in-yyyy-mm-dd-hhmmss-in-php – Sanooj T Apr 08 '16 at 07:10
  • 1
    Where did that string come from in the first place? If you can possibly avoid getting it as a string (e.g. using a `Date` as your input instead) that would be useful... – Jon Skeet Apr 08 '16 at 07:13

1 Answers1

0

If you want to get "YYYY-MM-DD" formate of mysql date format this code could help.

        DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("YYYY-MM-dd");
        DateTimeFormatter formatter=DateTimeFormatter.ofPattern("EEE MMM dd yyyy hh:mm:ss zZ (z)");
        TemporalAccessor parse = formatter.parse("Fri Apr 08 2016 00:00:00 GMT+0530 (IST)");
        LocalDate localDate=LocalDate.from(parse);
        String formated= dateTimeFormatter.format(localDate);

        System.out.println("formated:"+formated);
Mitiku
  • 5,337
  • 3
  • 18
  • 35