Answer the question
In order to leave comments, you need to log in
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(т.е не парсит месяц)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question