format() of Date doesn't respect user locale

Bug #519710 reported by j_soderstrom
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
play framework
Status tracked in 1.0
1.0
Fix Released
Undecided
Erwan Loisant
1.1
Fix Committed
Undecided
Erwan Loisant

Bug Description

When using the format(Date date) method from JavaExtensions the users Locale is not used. Because of this names of months and weekdays will appear in the wrong language.

Proposed fix:

    public static String format(Date date, String pattern) {
        return new SimpleDateFormat(pattern, Lang.getLocale()).format(date);
    }

    public static String format(Date date) {
        return new SimpleDateFormat(I18N.getDateFormat(), Lang.getLocale()).format(date);
    }

Revision history for this message
nkmrshn (nkmrshn) wrote :

I had the same problem when I was doing the tutorial and I fixed the format method(JavaExtensions.java) like this,

public static String format(Date date, String pattern) {
    return new SimpleDateFormat(pattern, new Locale(Lang.get())).format(date);
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.