Domanda

    SimpleDateFormat formato =new SimpleDateFormat("HH:mm:ss");
    Calendar cal = Calendar.getInstance();
    String fecha11 = String.valueOf(formato.format(cal.getTime()));

    Locale locale = new Locale("es", "ES");
    SimpleDateFormat format = new SimpleDateFormat("HH:MM:ss", locale);
    String fecha22 = String.valueOf(format.format(cal.getTime()));

Results: 14:06:12 (same that hour in my device) 14:16:55 (with Locale("es", "ES"))

And yes, i am in Spain (Bcn) ¬¬' somebody would explain me why?? And next question, is it happen when i change Locale to others countries?

Thanks,

Àlex

È stato utile?

Soluzione

In your second example: SimpleDateFormat format = new SimpleDateFormat("HH:MM:ss", locale);, you are using MM instead of mm, so it is the month number instead of the minutes that gets printed (is should be 05 for May though).

Altri suggerimenti

mm is minutes. MM is month

your second format is Hour:Month:Seconds

edited after assylias comment

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top