How do I get Hours and Minutes left from a UTC for...
# android
s
How do I get Hours and Minutes left from a UTC formatted data and time string? I am looking at
Duration
class. Is that the right approach?
2021-08-17T12:00:00.235Z
- Give a time like this, I need to find the hours and mins left from my local time.
c
I think you should take a look at
DateUtils.getRelativeTimeSpanString()
it requires a millisecond timestamp, but will provide you with something like this
👍 1
s
Thanks, Christiano. Looking at it.
t
You can use JSR-310 classes to format a duration however you like, using the
to<TimeUnit>Part()
methods.
There is also a jsr310 extra formatter that has an opinionated version of this, but it is less configurable.