Class DateUtils


  • public class DateUtils
    extends Object
    Testing utilities to work with dates
    • Method Detail

      • today

        public static Date today()
        Gets today's date
        Returns:
        a Date with the date of today
      • yesterday

        public static Date yesterday()
        Gets yesterday's date
        Returns:
        a Date with the day of yesterday
      • tomorrow

        public static Date tomorrow()
        Gets tomorrow's date
        Returns:
        a Date with the date of tomorrow
      • daysAgo

        public static Date daysAgo​(int days)
        Gets the date of n days ago starting from today
        Parameters:
        days - The number of days to be subtracted to the current date
        Returns:
        a Date with the date of n days ago, where n is the provided value.
      • daysAfter

        public static Date daysAfter​(int days)
        Gets the date of n days after today
        Parameters:
        days - The number of days to be added to the current date
        Returns:
        a Date with the date of n days after, where n is the provided value.
      • hoursAgo

        public static Instant hoursAgo​(int hoursAgo)
        Gets the Instant of n hours ago starting from now
        Parameters:
        hoursAgo - The number of hours to be subtracted
        Returns:
        the current Instant minus the specified number of hours