Class TimePeriodUtils


  • public class TimePeriodUtils
    extends Object
    some utilities for the TimePeriod interface
    Author:
    markr
    • Constructor Detail

      • TimePeriodUtils

        public TimePeriodUtils()
    • Method Detail

      • comparatorByStartTime

        public static Comparator<TimePeriod> comparatorByStartTime()
        custom comparator not by id but based on the start time and when equal duration
        Returns:
        comparator by start time
      • convertHoursToSeconds

        public static long convertHoursToSeconds​(String fourDigitHour)
                                          throws PlanItException
        Convert duration to seconds given start time using the 24-hour clock
        Parameters:
        fourDigitHour - start time in 24-hour clock format (four digits exactly)
        Returns:
        duration in seconds
        Throws:
        PlanItException - thrown if the input time is not in the correct format
      • convertHoursToSeconds

        public static long convertHoursToSeconds​(double hoursFromMidnight)
        Convert hours to (whole) seconds
        Parameters:
        hoursFromMidnight - the hours from midnight
        Returns:
        secondsFromMidnight the seconds from midnight
      • convertSecondsToHours

        public static float convertSecondsToHours​(int secondsFromMidnight)
        Convert seconds to 24h format from midnight to seconds
        Parameters:
        secondsFromMidnight - seconds from midnight
        Returns:
        hours from midnight