Display date AND time in user locale

后端 未结 2 1013
小鲜肉
小鲜肉 2021-02-07 10:13

I know I can use android.text.format.DateFormat.getDateFormat() to format my dates, and android.text.format.DateFormat.getTimeFormat to format my times

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-07 10:22

    To extend the answer, here's a functional example

    DateUtils.formatDateTime(context, epochTimeInMs, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_DATE);
    

    This would print Apr 8 for a US Locale, or 8 de abr for a Spanish Locale

    You can see the full list of valid flags at DateUtils documentation

提交回复
热议问题