Class RandomDateFactory


  • public final class RandomDateFactory
    extends java.lang.Object
    The factory class RandomDateFactory for creating random Date objects
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Date dateAfter​(java.util.Date date, int range, java.security.SecureRandom secureRandom)
      Creates a random Date that is after from the given Date.
      static java.util.Date dateBefore​(java.util.Date date, int range, java.security.SecureRandom secureRandom)
      Creates a random date that is before from the given date.
      static java.util.Date randomDate​(java.security.SecureRandom secureRandom)
      Creates a random Date
      static java.util.Date randomDate​(java.util.Date from, java.security.SecureRandom secureRandom)
      Creates a random date.
      static java.lang.String randomDateBetween​(long startDate, long endDate, java.lang.String format, java.security.SecureRandom secureRandom)
      Creates a random Date between the range from startDays and endDays from the given Date and gives it back as a string to the given format.
      static java.util.Date randomDateBetween​(java.util.Date start, java.util.Date end, java.security.SecureRandom secureRandom)
      Creates a random Date between the range from start and end.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • dateAfter

        public static java.util.Date dateAfter​(java.util.Date date,
                                               int range,
                                               java.security.SecureRandom secureRandom)
        Creates a random Date that is after from the given Date.
        Parameters:
        date - The Date from where to compute the future date.
        range - The range.
        secureRandom - the secure random for Date generation
        Returns:
        The random Date in the future.
      • dateBefore

        public static java.util.Date dateBefore​(java.util.Date date,
                                                int range,
                                                java.security.SecureRandom secureRandom)
        Creates a random date that is before from the given date.
        Parameters:
        date - The date from where to compute the past date.
        range - The range.
        secureRandom - the secure random for Date generation
        Returns:
        The random Date in the past.
      • randomDate

        public static java.util.Date randomDate​(java.util.Date from,
                                                java.security.SecureRandom secureRandom)
        Creates a random date.
        Parameters:
        from - The date from where to begin.
        secureRandom - the secure random for date generation
        Returns:
        The random date.
      • randomDate

        public static java.util.Date randomDate​(java.security.SecureRandom secureRandom)
        Creates a random Date
        Parameters:
        secureRandom - the secure random for Date generation
        Returns:
        The random Date
      • randomDateBetween

        public static java.util.Date randomDateBetween​(java.util.Date start,
                                                       java.util.Date end,
                                                       java.security.SecureRandom secureRandom)
        Creates a random Date between the range from start and end.
        Parameters:
        start - The Date from where the range starts.
        end - The Date from where the range ends.
        secureRandom - the secure random for date generation
        Returns:
        A random Date between the range from start and end.
      • randomDateBetween

        public static java.lang.String randomDateBetween​(long startDate,
                                                         long endDate,
                                                         java.lang.String format,
                                                         java.security.SecureRandom secureRandom)
        Creates a random Date between the range from startDays and endDays from the given Date and gives it back as a string to the given format.
        Parameters:
        startDate - The date from where to start as a long.
        endDate - The date from where to end as a long.
        format - The format for the date.
        secureRandom - the secure random for String generation
        Returns:
        The random date as a String.