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?
MMMfor parsingDec- YuriiSPb ♦Date date2 = newDateFormat.parse(result);? The date in the required string format already lies in theresult, the date in the date format lies in thedate. - Enikeyschik