I don't know what is wrong with your code, but this code works for me:
DateFormat df = new SimpleDateFormat("yyyyMMdd HH:mm"); String sdt = df.format(new Date(System.currentTimeMillis())); System.out.println(sdt);
EDIT:
I later found out that your source code should work with this:
String sdt_ = DateFormat.format("yyyyMMdd kk:mm", dt_).toString();
obviously android.text.format.DateFormat does not use the "H" constraint and uses the "k" instead! see this question for more details: How to set 24 hour date format in java?
source share