Skip to content

Instantly share code, notes, and snippets.

@knowsuchagency
Created September 15, 2017 05:33
Show Gist options
  • Save knowsuchagency/d873216dc056bb0791557e5f8cfcc451 to your computer and use it in GitHub Desktop.
Save knowsuchagency/d873216dc056bb0791557e5f8cfcc451 to your computer and use it in GitHub Desktop.
null created by knowsuchagency - https://repl.it/LIK8/0
class Main {
public static void main(String[] args) {
int seconds, minutes, hours, days, weeks;
seconds = 100;
weeks = seconds/(168*60*60);
seconds -= weeks*168*60*60;
days = seconds/(24*60*60);
seconds -= days*24*60*60;
hours = seconds/(60*60);
seconds -= hours*60*60;
minutes = seconds/(60);
seconds -= minutes*60;
if (weeks > 0) {
System.out.printf("%d weeks %d days %d hours %d minutes %d seconds", weeks, days, hours, minutes, seconds);
} else if (days > 0) {
System.out.printf("%d days %d hours %d minutes %d seconds", days, hours, minutes, seconds);
} else if (hours > 0) {
System.out.printf("%d hours %d minutes", hours, minutes, seconds);
} else if (minutes > 0) {
System.out.printf("%d minutes %d seconds", minutes, seconds);
} else {
System.out.printf("%d seconds", seconds);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment