Interface IDateService

  • All Known Implementing Classes:
    DateService

    public interface IDateService
    Author:
    Andi Hotz, (c) Sahits GmbH, 2019 Created on Jan 05, 2019
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getAge​(java.time.LocalDateTime birthDate)
      Calculate the age.
      double getPercentageBetweenDates​(java.time.LocalDateTime start, java.time.LocalDateTime end)
      Calculate the percentage of days passed between the start and end date.
      boolean isPast​(java.time.LocalDateTime date)
      Check if a date lies in the past.
      boolean isSameDay​(java.time.LocalDateTime date1, java.time.LocalDateTime date2)
      Check if two dates represent the same day
      boolean isToday​(java.time.LocalDateTime date)
      Check if the date is today.
    • Method Detail

      • isSameDay

        boolean isSameDay​(java.time.LocalDateTime date1,
                          java.time.LocalDateTime date2)
        Check if two dates represent the same day
        Parameters:
        date1 - first date to compair
        date2 - second date to compair
        Returns:
        true if both dates are on the same day
      • isToday

        boolean isToday​(java.time.LocalDateTime date)
        Check if the date is today.
        Parameters:
        date - to chack against the current date
        Returns:
        true if date is on the same day as current date
      • isPast

        boolean isPast​(java.time.LocalDateTime date)
        Check if a date lies in the past.
        Parameters:
        date - to be checked.
        Returns:
        true if the date is before the current game date
      • getPercentageBetweenDates

        double getPercentageBetweenDates​(java.time.LocalDateTime start,
                                         java.time.LocalDateTime end)
        Calculate the percentage of days passed between the start and end date.
        Parameters:
        start - date
        end - date
        Returns:
        percentage of days passed in [0,1]
      • getAge

        int getAge​(java.time.LocalDateTime birthDate)
        Calculate the age.
        Parameters:
        birthDate - from which to calculate the age
        Returns:
        age in years