Java Long Number to Time convertTimeToInt(long seconds)

Here you can find the source of convertTimeToInt(long seconds)

Description

Converts a long seconds value to an int seconds value and takes into account overflow from the downcast by switching to Integer.MAX_VALUE.

License

Apache License

Parameter

Parameter Description
seconds Long value

Return

Same int value unless long > Integer.MAX_VALUE in which case MAX_VALUE is returned

Declaration

public static int convertTimeToInt(long seconds) 

Method Source Code

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

public class Main {
    /**//w ww  .  j a v a  2s . com
     * Converts a long seconds value to an int seconds value and takes into account overflow
     * from the downcast by switching to Integer.MAX_VALUE.
     * @param seconds Long value
     * @return Same int value unless long > Integer.MAX_VALUE in which case MAX_VALUE is returned
     */
    public static int convertTimeToInt(long seconds) {
        if (seconds > Integer.MAX_VALUE) {
            return Integer.MAX_VALUE;
        } else {
            return (int) seconds;
        }
    }
}

Related

  1. convertTime(long time)
  2. convertTime(long value)
  3. convertTime(long x)
  4. convertTimestampToSec(long timestampInMs)
  5. convertTimestampToUTCString(final long aTimestamp)
  6. convertTimeToString(final long time)
  7. convertTimeToString(final long timeInMillis)
  8. convertTimeUnit(long epochTime, String timeUnit)
  9. convertTimeUnit(long epochTime, String timeUnit)