M mjcoon Well-Known Member Licensed User Feb 29, 2020 #1 I thought I would be able to use DateTime.Time() to display a duration which happens to originate in milliseconds (from SimpleExoPlayer). My first test value was 311797mS, or ~311 seconds or ~5minutes. But what I see is "01:05:11", in other words an extra hour. I can hardly add a negative hour's worth of millliseconds and expect to get a sensible answer. And DateTime is only specified to be relative to 1 January 1970, not to 01:00 on that date. So what is recoommended for displaying durations in HH:MM:SS elapsed?
I thought I would be able to use DateTime.Time() to display a duration which happens to originate in milliseconds (from SimpleExoPlayer). My first test value was 311797mS, or ~311 seconds or ~5minutes. But what I see is "01:05:11", in other words an extra hour. I can hardly add a negative hour's worth of millliseconds and expect to get a sensible answer. And DateTime is only specified to be relative to 1 January 1970, not to 01:00 on that date. So what is recoommended for displaying durations in HH:MM:SS elapsed?
M Mahares Expert Licensed User Longtime User Feb 29, 2020 #2 mjcoon said: So what is recoommended for displaying durations in HH:MM:SS elapsed? Click to expand... Code: Copy Dim m As Long = 311797 Dim p As Period = DateUtils.PeriodBetween(0,m) Log($"$2.0{p.Hours}:$2.0{p.Minutes}:$2.0{p.Seconds}"$) 'displays 00:05:11 Upvote 0
mjcoon said: So what is recoommended for displaying durations in HH:MM:SS elapsed? Click to expand... Code: Copy Dim m As Long = 311797 Dim p As Period = DateUtils.PeriodBetween(0,m) Log($"$2.0{p.Hours}:$2.0{p.Minutes}:$2.0{p.Seconds}"$) 'displays 00:05:11
Erel B4X founder Staff member Licensed User Longtime User Mar 1, 2020 #3 mjcoon said: I thought I would be able to use DateTime.Time() Click to expand... This is a common mistake. Watch the date and time video tutorial for more information: https://www.b4x.com/etp.html Convert milliseconds to time string: https://www.b4x.com/android/forum/threads/b4x-convert-milliseconds-to-string.89851/#content Upvote 0
mjcoon said: I thought I would be able to use DateTime.Time() Click to expand... This is a common mistake. Watch the date and time video tutorial for more information: https://www.b4x.com/etp.html Convert milliseconds to time string: https://www.b4x.com/android/forum/threads/b4x-convert-milliseconds-to-string.89851/#content