Java Utililty Methods Second

List of utility methods to do Second

Description

The list of methods to do Second are organized into topic(s).

Method

longcurrentSecondsPlus(final long seconds)
current Seconds Plus
return currentSeconds() + seconds;
int[]dateArrayFromSeconds(int inSeconds)
Given a number of seconds, creates an int[] detailing the months, days, and hours difference as well.
int days = (int) (inSeconds / (60 * 60 * 24));
inSeconds -= (days * 60 * 60 * 24);
int hours = (int) (inSeconds / (60 * 60));
inSeconds -= (hours * 60 * 60);
int minutes = (int) (inSeconds / 60);
inSeconds -= (minutes * 60);
return new int[] { days, hours, minutes, inSeconds };
longdateDiffToSeconds(final String diff)
parse a string to get time span in seconds
long secs = 0;
final String[] units = diff.split("[.]");
for (final String unit : units) {
    if (unit.matches("[dhms][0-9]+")) {
        final char unitdesc = unit.charAt(0);
        switch (unitdesc) {
        case 's':
            secs += Integer.parseInt(unit.replace("s", ""));
...
longHoursToSeconds(final float hours)
Hours To Seconds
return (long) (hours * MINUTES_IN_AN_HOUR * SECONDS_IN_A_MINUTE);
booleanisSecondsWholeHour(long secs)
is Seconds Whole Hour
return (hoursToSecs(secsToHours(secs))) == secs;
Stringsecond2time(int seconds)
secondtime
int hour = seconds / 3600;
int other = seconds % 3600;
int minute = other / 60;
int second = other % 60;
StringBuilder sb = new StringBuilder();
if (hour < 10) {
    sb.append("0");
sb.append(hour);
sb.append(":");
if (minute < 10) {
    sb.append("0");
sb.append(minute);
sb.append(":");
if (second < 10) {
    sb.append("0");
sb.append(second);
return sb.toString();
intseconds(int num)
seconds
return TICKS_PER_SECOND * num;
intseconds(int s)
seconds
return s * 1000;
longseconds(int seconds)
seconds
return seconds * ONE_SECOND_IN_MILLIS;
StringsecondsAfterMidnightToClock(int secondsAfterMidnight)
Convert seconds after midnight to 24hr clock time like "06:00:00"
return String.format("%02d:%02d:%02d", secondsAfterMidnight / 3600, (secondsAfterMidnight / 60) % 60,
        secondsAfterMidnight % 60);