Konvertieren Sie das Datum mit simpledateformat in einen String
Beim Konvertieren eines Datums in eine Zeichenfolge in einem anderen Format treten Probleme auf. Das Datum:
lastDownloadDate>>Wed Feb 27 16:20:23 IST 2013
lastChangeDate>>Wed Feb 27 15:11:00 IST 2013
Ich möchte dieses Format in ein anderes Format konvertieren:yyyy-mm-dd HH:mm:ss
.
Wenn ich versuche, es zu konvertieren, erhalte ich unterschiedliche Ergebnisse mit:
DateFormat outputFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
String lastDownloadTimeVal = outputFormat.format(lastDownloadDate);
System.out.println("lastDownloadTimeVal>>"+lastDownloadTimeVal);
String lastChangeTimeVal = outputFormat.format(lastChangeDate);
System.out.println("lastChangeTimeVal>>"+lastChangeTimeVal);
Ich erhalte das falsche Ergebnis, der Monat wird durch Minuten ersetzt:
lastDownloadTimeVal>>2013-20-27 16:20:23
lastChangeTimeVal>>2013-11-27 15:11:00