Package records.util

Class DateTimeCalculator

java.lang.Object
records.util.DateTimeCalculator

public class DateTimeCalculator extends Object
Utility class for date and time calculations. Provides methods for calculating total hours worked, total overtime hours, regular hours worked, adjusted time in, total number of days, months, and years between two dates, and calculating overtime hours.

Available methods:

  • Constructor Details

    • DateTimeCalculator

      public DateTimeCalculator()
  • Method Details

    • totalHoursWorked

      public static double totalHoursWorked(List<AttendanceRecord> attendanceRecordList)
      Calculates the total hours worked based on a list of attendance records.
      Parameters:
      attendanceRecordList - the list of attendance records
      Returns:
      the total hours worked
    • totalOvertimeHours

      public static double totalOvertimeHours(List<AttendanceRecord> attendanceRecordList)
      Calculates the total overtime hours based on a list of attendance records.
      Parameters:
      attendanceRecordList - the list of attendance records
      Returns:
      the total overtime hours
    • regularHoursWorked

      public static LocalTime regularHoursWorked(LocalTime timeIn, LocalTime timeOut)
      Calculates the regular hours worked between two times.
      Parameters:
      timeIn - the time in
      timeOut - the time out
      Returns:
      the regular hours worked
    • adjustedTimeIn

      public static LocalTime adjustedTimeIn(LocalTime timeIn)
      Adjusts the time in if it's before or equal to the grace period.
      Parameters:
      timeIn - the time in
      Returns:
      the adjusted time in
    • totalDays

      public static int totalDays(List<AttendanceRecord> attendanceRecordList)
      Calculates the total number of days from a list of attendance records.
      Parameters:
      attendanceRecordList - the list of attendance records
      Returns:
      the total number of days
    • totalDays

      public static int totalDays(LocalDate startDate, LocalDate endDate)
      Calculates the total number of days between two dates.
      Parameters:
      startDate - the start date
      endDate - the end date
      Returns:
      the total number of days
    • totalMonths

      public static int totalMonths(LocalDate startDate, LocalDate endDate)
      Calculates the total number of months between two dates.
      Parameters:
      startDate - the start date
      endDate - the end date
      Returns:
      the total number of months
    • totalYears

      public static int totalYears(LocalDate startDate, LocalDate endDate)
      Calculates the total number of years between two dates.
      Parameters:
      startDate - the start date
      endDate - the end date
      Returns:
      the total number of years
    • overtimeHours

      public static LocalTime overtimeHours(LocalTime timeIn, LocalTime timeOut)
      Calculate overtime hours based on the time in and time out.
      Parameters:
      timeIn - the starting time
      timeOut - the ending time
      Returns:
      the total overtime hours