Package com.smell.application.structure
Class ComparisonService
java.lang.Object
com.smell.application.structure.ComparisonService
Provides utility methods to compare date and time ranges for different entities in the system.
This service is used to determine whether two given time periods overlap using precise date-time parsing.
It supports handling 'now' as a dynamic reference to the current time in UTC for comparisons.
The service logs detailed information about parsing errors and operational steps to facilitate debugging and ensure reliable operations.
- Since:
- 24/04/24
- Version:
- ${version}
- Author:
- FlynnDynamics
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ComparisonService
public ComparisonService()
-
-
Method Details
-
isTimeWithinRange
Determines whether two time periods overlap. Each time period is defined by a start and an end datetime string in ISO_OFFSET_DATE_TIME format. This method parses the datetime strings and checks if the two periods overlap.- Parameters:
startA- The start datetime of the first period.endA- The end datetime of the first period.startB- The start datetime of the second period.endB- The end datetime of the second period.- Returns:
- true if the periods overlap, false otherwise.
- Throws:
DateTimeParseException- if any datetime string cannot be parsed correctly, indicating a potential input error.
-
getCurrentUTCTime
Retrieves the current UTC time as a formatted string in ISO_OFFSET_DATE_TIME format. Logs the current time to assist with debugging or logging time-sensitive operations.- Returns:
- The current UTC time as a string formatted according to ISO_OFFSET_DATE_TIME.
-