Java Second Convert convertSecondsToTimeUnits(int seconds)

Here you can find the source of convertSecondsToTimeUnits(int seconds)

Description

convert Seconds To Time Units

License

LGPL

Declaration

public static int[] convertSecondsToTimeUnits(int seconds) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    private static final int MINUTE = 60;
    private static final int HOUR = 60 * MINUTE;
    private static final int DAY = 24 * HOUR;

    public static int[] convertSecondsToTimeUnits(int seconds) {

        int[] timeUnits = new int[4];
        int remnant = seconds;
        if (remnant >= DAY) {
            timeUnits[0] = remnant / DAY;
            remnant = remnant % DAY;//  w  w w.ja  v a 2  s  .  c o m
        }

        if (remnant >= HOUR) {
            timeUnits[1] = remnant / HOUR;
            remnant = remnant % HOUR;
        }

        if (remnant >= MINUTE) {
            timeUnits[2] = remnant / MINUTE;
            remnant = remnant % MINUTE;
        }

        timeUnits[3] = remnant;

        return timeUnits;
    }
}

Related

  1. convertSecondsToMillies(final long seconds)
  2. convertSecondsToString(double seconds)
  3. convertSecondsToTime(int seconds)
  4. convertSecondsToTime(int totalSecs)
  5. convertSecondsToTimecode(float totalSeconds)
  6. convertTimecodeToSeconds(String timecode)
  7. convertTimemilisecondsToHours(long time)
  8. convertTimeSecondsToHMS(long longSecs)
  9. convertTimeToSeconds(String a_time)