Android:如何以用户的语言获取当前的星期几(星期一等)? [英] Android: how to get the current day of the week (Monday, etc...) in the user's language?

查看:19
本文介绍了Android:如何以用户的语言获取当前的星期几(星期一等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当前的星期几(星期一、星期二...),用用户的本地语言表示.例如,Lundi"狂欢"等等...如果用户是法国人.

I want to know what the current day of the week is (Monday, Tuesday...) in the user's local language. For example, "Lundi" "Mardi" etc... if the user is French.

我已经阅读了这篇文章,但它只返回一个整数,而不是用户语言的日期字符串:在 Android 中获取当前星期几的最简单方法是什么?

I have read this post, it but it only returns an int, not a string with the day in the user's language: What is the easiest way to get the current day of the week in Android?

更一般地说,如何以用户的语言编写一周中的所有日子和一年中的所有月份?

More generally, how do you get all the days of the week and all the months of the year written in the user's language ?

我认为这是可能的,例如,Google 议程以用户的当地语言给出了日期和月份.

I think that this is possible, as for example the Google agenda gives the days and months written in the user's local language.

推荐答案

使用 SimpleDateFormat 来根据用户的区域设置,将日期和时间格式化为人类可读的字符串.

Use SimpleDateFormat to format dates and times into a human-readable string, with respect to the users locale.

获取当前星期几的小例子(例如星期一"):

Small example to get the current day of the week (e.g. "Monday"):

SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
Date d = new Date();
String dayOfTheWeek = sdf.format(d);

这篇关于Android:如何以用户的语言获取当前的星期几(星期一等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆