patrick1980 patrick1980 - 1 year ago 102
Android Question

SimpleDateFormat did not work

I wanted to change the format (from 12 to 24hours) saves your time and found on stack how to do it

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy HH:mm:ss");

String currentDateTimeString = dateFormat.getDateTimeInstance().format(new Date());

but not that still works and saves Form A.M/P.M

why it does not work?

Answer Source

You call the static method getDateTimeInstance(), which creates a new SimpleDateFormat instance, instead of using the SimpleDateFormat you just created:

dateFormat.format(new Date());

Also, you're using mm (minutes) instead of MM (months).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download