Created
August 1, 2021 09:15
-
-
Save Ankit-Slnk/8e77a2b456b2e02e33227c1a13d218df to your computer and use it in GitHub Desktop.
Get hh:mm:ss from seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String getHMS(int seconds) { | |
if (seconds == null) return ""; | |
final int minutes = (seconds / 60).truncate(); | |
final int hours = (minutes / 60).truncate(); | |
String secondsStr = (seconds % 60).toString().padLeft(2, '0'); | |
String minutesStr = (minutes % 60).toString().padLeft(2, '0'); | |
String hoursStr = (hours % 60).toString().padLeft(2, '0'); | |
return "$hoursStr.$minutesStr.$secondsStr"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment