Code:

Person person = allPeople.get(id); // принимаем строчку Wed Dec 09 00:00:00 MSK 1998 и переводим в oldDateFormat: String string = allPeople.get(id).getBirthDay().toString(); SimpleDateFormat oldDateFormat = new SimpleDateFormat("E MM hh:mm:ss z yyyy", Locale.ENGLISH); SimpleDateFormat newDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); // date "забирает" на себя отформатированную ранее строку: Date date = oldDateFormat.parse(string); // и пробуем привести под более читабельный формат dd-MM-yyyy: String result = newDateFormat.format(date); Date date2 = newDateFormat.parse(result); 

As a result, the exception is:

ParseException: Unparseable date.

Did I incorrectly set the notation in oldDateFormat ? Or what's the problem?

  • one
    Try MMM for parsing Dec - YuriiSPb
  • Why do you need to parse the date? - Roman C
  • Why do we need the line Date date2 = newDateFormat.parse(result); ? The date in the required string format already lies in the result , the date in the date format lies in the date . - Enikeyschik

0