开发者

How to display month and week days in other languages in AppEngine?

开发者 https://www.devze.com 2023-03-01 07:41 出处:网络
Is there 开发者_如何学Goa way to display month and week days names in a language different to English with AppEngine?

Is there 开发者_如何学Goa way to display month and week days names in a language different to English with AppEngine?

Thanks!


For the Python runtime, locale is unavailable, but Django 1.2 templates support format localization.


Of course there is. Just use correct Locale. For example:

    Date now = new Date();
    DateFormat monthFormat = new SimpleDateFormat("MMMM", Locale.FRENCH);
    String currentMonth = monthFormat.format(now);

Day names are accessible via similar pattern. Other example:

    DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.GERMAN);
    String date = df.format(now);

However, I would recommend using DEFAULT pattern:

    DateFormat dateFormat = DateFormat.getDateTimeInstance(
            DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.ITALIAN);
    String defaultDateTime = dateFormat.format(now);

As you can see it works just like in other Java based applications. That is unless you were asking for Python-based GAE...

0

精彩评论

暂无评论...
验证码 换一张
取 消