Class TimeUtil


  • public class TimeUtil
    extends java.lang.Object
    Utilities for converting times
    Author:
    Greg Luck
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int convertTimeToInt​(long seconds)
      Converts a long seconds value to an int seconds value and takes into account overflow from the downcast by switching to Integer.MAX_VALUE.
      static long toMillis​(int timeInSecs)
      Converts seconds to milliseconds, with a precision of 1 second
      static int toSecs​(long timeInMillis)
      Converts milliseconds to seconds
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TimeUtil

        public TimeUtil()
    • Method Detail

      • toSecs

        public static int toSecs​(long timeInMillis)
        Converts milliseconds to seconds
        Parameters:
        timeInMillis -
        Returns:
        The equivalent time in seconds
      • toMillis

        public static long toMillis​(int timeInSecs)
        Converts seconds to milliseconds, with a precision of 1 second
        Parameters:
        timeInSecs - the time in seconds
        Returns:
        The equivalent time in milliseconds
      • convertTimeToInt

        public static int convertTimeToInt​(long seconds)
        Converts a long seconds value to an int seconds value and takes into account overflow from the downcast by switching to Integer.MAX_VALUE.
        Parameters:
        seconds - Long value
        Returns:
        Same int value unless long > Integer.MAX_VALUE in which case MAX_VALUE is returned