Home » Android » Android DateUtils flags explained

Android DateUtils flags explained

Posted by: admin June 15, 2020 Leave a comment


I am using getRelativeTimeSpanString (long time, long now, long minResolution, int flags) to calculate a relative date. The docs say that flags is “a bit mask of formatting options, such as FORMAT_NUMERIC_DATE or FORMAT_ABBREV_RELATIVE”. However, there are about a dozen other flags defined in DateUtils, and the only ones with any description at all are deprecated.

  1. Is it possible to use any of the other flags with getRelativeTimeSpanString()?
  2. What is the actual behavior of the other flags?
  3. Specifically, I’d like to come out with things like 5d, 6h, and 2m, but I’m not seeing anything that looks like it does that. Will I have to roll my own?
How to&Answers:

They are all documented here: DateUtils.