The problem is you are using "MM" as minutes but it should be "mm". "MM" is for months.
The part "HH" is fine when you want the 24 hour values back.
try soemthing like this:
public static String getTimeFormatted(String time){
String s = "";
try{
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm aa", Locale.US);
Date d = sdf.parse(time);
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm", Locale.US);
s = formatter.format(d);
}
catch(Exception ex){
s = ex.getMessage();
}
return s;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…