Package org.goplanit.utils.time
Class TimePeriodUtils
- java.lang.Object
-
- org.goplanit.utils.time.TimePeriodUtils
-
public class TimePeriodUtils extends Object
some utilities for the TimePeriod interface- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description TimePeriodUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Comparator<TimePeriod>
comparatorByStartTime()
custom comparator not by id but based on the start time and when equal durationstatic long
convertHoursToSeconds(double hoursFromMidnight)
Convert hours to (whole) secondsstatic long
convertHoursToSeconds(String fourDigitHour)
Convert duration to seconds given start time using the 24-hour clockstatic float
convertSecondsToHours(int secondsFromMidnight)
Convert seconds to 24h format from midnight to seconds
-
-
-
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
-
-