Can someone show me an example how to properly use the getRelativeDateTimeString()
that is detailed here.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I think a better question would specify what you want as an output. However, here's an example:
This will format
theEventInMillis
relative to whatever the system's current time is. It will show changes in minutes (0 minutes ago, 2 minutes ago, 3 hours ago, 1 day ago, etc) until the difference reaches a week, then it will just post the full date. The flags field (0 in this case, last argument) you can use to control how the resulting string is rendered, but you should check the docs to see what fits your needs.I guess you are talking about
getRelativeDateTimeString
, which is pointed to by your link.Example for
now
, with comments detailing all params:Other values for
MINUTE_IN_MILLIS
andYEAR_IN_MILLIS
include:SECOND_IN_MILLIS
MINUTE_IN_MILLIS
HOUR_IN_MILLIS
DAY_IN_MILLIS
WEEK_IN_MILLIS
YEAR_IN_MILLIS