Java Second Convert secondsToInternal(int seconds)

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

Description

Helper method that converts from seconds into internal time unit (which is approximately "quarter of a second")

License

Open Source License

Declaration

public static int secondsToInternal(int seconds) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from www .  jav a  2 s .  c  o  m
     * Constants we use to check whether conversion to "quarters" can be
     * done using just ints
     */
    private final static int MAX_SECONDS_FOR_INT = Integer.MAX_VALUE / 1000;

    /**
     * Helper method that converts from seconds into internal time unit
     * (which is approximately "quarter of a second")
     */
    public static int secondsToInternal(int seconds) {
        // fastest way is without converting to long, can be used for most cases:
        if (seconds < MAX_SECONDS_FOR_INT) {
            return (seconds * 1000) >>> 8;
        }
        // if not, use long
        long msecs = 1000L * seconds;
        return (int) (msecs >>> 8);
    }
}

Related

  1. secondsToHHMMSS(int secs)
  2. secondsToHHMMSS(long secs)
  3. secondsToHour(int time)
  4. secondsToHours(double seconds)
  5. secondsToHours(int s)
  6. secondsToNanoseconds(long seconds)
  7. secondsToReadableBiggest(int seconds)
  8. secondsToString(int seconds)
  9. secondsToString(long seconds)