E
E
Eserchik2017-04-11 12:42:15
Java
Eserchik, 2017-04-11 12:42:15

Java - date formatting issues, MMM(Apr)->mm(04) not converted?

Good afternoon, help solve the problem:
The task is to bring the date to the desired format yyyy-mm-dd, the problem is in parsing MMM(Apr)->mm(04)

DateFormat shortFormat = new SimpleDateFormat("yyyy-mm-dd",Locale.US);
        DateFormat fullFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy",Locale.US);
        String s = "Fri Apr 07 00:00:00 MSK 2017";
        String shortDate = null;
        try {
            shortDate = shortFormat.format(fullFormat.parse(s));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("shortDate: "+shortDate);//Выводит 2017-00-07(т.е не парсит месяц)
    }

That is, the name of the month in MMM format cannot be converted to mm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
al_gon, 2017-04-11
@al_gon

mm is minutes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question