Question

    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

Était-ce utile?

La solution

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).

Autres conseils

mm is minutes. MM is month

your second format is Hour:Month:Seconds

edited after assylias comment

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top