【问题标题】:How to get date format for specific country in my android Date picker?如何在我的 android 日期选择器中获取特定国家/地区的日期格式?
【发布时间】:2014-06-04 13:02:28
【问题描述】:

我想制作一个代码来通过 android 日期选择器中的国家名称获取国家日期格式。 我尝试使用 Locale.getDefault 来获取当前的国家日期格式。但我需要通过 android 中的国家名称的日期格式。请帮助我完成这项任务。

【问题讨论】:

    标签: android datepicker locale date-format


    【解决方案1】:

    使用android.text.format.DateFormat.getDateFormat(Context)

    DateFormat dateFormat = DateFormat.getDateFormat(Context);
    String dateString = dateFormat.format(Date);
    

    【讨论】:

    • 这是什么我想在我的日期选择器 android 中获取当前国家/地区的日期格式。这不起作用。
    • 在这段代码中,你必须设置“日期”,你想显示的时间是什么。
    • 在“android.text.format.DateFormat.getDateFormat(Context)”这个链接。文档说明:返回一个 DateFormat 对象,该对象可以根据当前语言环境和用户的日期顺序偏好以短格式(例如 12/31/1999)格式化日期。不是吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    • 1970-01-01
    • 2013-01-28
    相关资源
    最近更新 更多