-2
Ich habe das Datum "2016-08-05 14:46:53 +05: 30" und das Datum und Uhrzeitformat, das ich verwendet habe, ist "yyyy-MM-DD HH : mm: ss +05: 30 " das problem ist, dass, wenn ich dieses datum analysiere ich bekomme die ausgabe " Di Jan 05 14:46:53 GMT + 05: 30 2016 " ich verstehe nicht was ist das Problem. Der Code, den ich verwende, ist unten veröffentlicht.Datum und Uhrzeit Formatierungsfehler
public class DateFormater {
private static String DATE_TIME_FORMAT = "yyyy-MM-DD HH:mm:ss +05:30";
private static String TAG = DateFormater.class.getSimpleName();
public static Date getDate(String s) {
//Input s = 2016-08-05 14:46:53 +05:30
Date date = null;
try {
SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_TIME_FORMAT);
date=dateFormat.parse(s);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static String getCurrentDateString(Date date) {
DateFormat dateFormat=SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
Log.i(TAG, "getCurrentDateString: "+dateFormat.format(date));
return dateFormat.format(date);
}
public static String getCurrentTimeString(Date date) {
DateFormat dateFormat=SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
return dateFormat.format(date);//Tue Jan 05 14:46:53 GMT+05:30 2016
}}
'DD' ist nicht das Token, nach dem Sie suchen, verwenden Sie' dd'. – Tunaki
Bekam Kumpel. Danke – ESHVAR289