Q:

Android SimpleDateFormat not setting a custom pattern

I have tried changing the format of the date given by location.getTime() from the default format:
dd/MM/yyyy HH:mm:ss

to this format:
yyyyMMddHHmmss

using the following code:
private String timeAsString (Location location) {
// code taken from: stackoverflow.com/questions/12747549/android-location-time-into-date
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
    Date date = new Date(location.getTime());
    return format.format(date);
}

However, my debugger says that format has the default format dd/MM/yyyy HH:mm:ss. How do I get the format to change to yyyyMMddHHmmss?

A:

You don't have a problem in your method. try cleaning the project and rebuild.

