I need to convert Long to Hours, Minutes and Seconds based on the long value range.
However, I need following conditional conversion:
If the Long value is less than 1 Hour, then the output should be in minutes.
e.g. if it is less than3_600_000L
the output is 59 minutes or likewise.If the Long value is equal to exact/complete/whole hour like 1 Hour/2 Hour or so, then the output should be in hours.
e.g. if it is3_600_000L
OR7_200_000L
the output is 1 Hour OR 2 Hours or likewise.If the Long Value is greater than hours and also has some minutes then the output should consist hours and minutes as well.
e.g. if it is7_400_000L
the output is 2 Hour, 3 MinuteIf the long value is greater than 1 Day (i.e. 24 Hours) and is equal to exact/complete/whole hour 24 Hours, 48 Hour then output should be 1 Day, 2 Days accordingly.
If the long value is greater than 1 Day and has some additional hours then the output should be 1 day, 5 hours.
Note:
- I studied already answered questions related to this topic but I could not find any solution, hence posting this query.
- I tried
Simple Date Format
andTimeUnit.MILLISECONDS.toHour
/toSeconds
/toMinute
s but it did not work. - I need this for Android with Kotlin
- I need to make a single function which accepts long and returns value based on above conditions.
Request you all to please guide.