Skip to content

Instantly share code, notes, and snippets.

@jayeshcp
Last active September 22, 2015 12:00
Show Gist options
  • Save jayeshcp/fbe4985a1b34e96fd33c to your computer and use it in GitHub Desktop.
Save jayeshcp/fbe4985a1b34e96fd33c to your computer and use it in GitHub Desktop.
Convert seconds to Days, Hours, Mins, Secs
public static void ConvertSec2DaysHoursMinsSecs(int timeDiff) {
int days = (int) Math.floor(timeDiff / 86400);
int hour = (int) Math.floor((timeDiff % 86400) / 3600);
int min = (int) Math.floor((timeDiff % 3600) / 60);
int sec = (int) (timeDiff % 60);
System.out.println("(" + days + " " + hour + " " + min + " " + sec + ")");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment