Class RandomDateFactory

java.lang.Object
io.github.astrapi69.random.date.RandomDateFactory

public final class RandomDateFactory extends Object
The factory class RandomDateFactory for creating random Date objects
  • Method Details

    • randomBirthday

      public static Date randomBirthday()
      Creates a random birthday-date between 9 and 55 years.
      Returns:
      's the random date.
    • randomBirthday

      public static Date randomBirthday(Date from, Date till)
      Creates a random birthday-date between the two given date-objects.
      Parameters:
      from - The date from where to start.
      till - The date from where to end.
      Returns:
      's the random date.
    • randomDateAfter

      public static Date randomDateAfter(Date date)
      Creates a random Date that is after from the given Date.
      Parameters:
      date - The Date from where to compute the future date.
      Returns:
      The random Date in the future.
    • randomDateAfter

      public static Date randomDateAfter(Date date, int range)
      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.
      Returns:
      The random Date in the future.
    • randomDateAfter

      public static Date randomDateAfter(Date date, int range, 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.
    • randomDateBefore

      public static Date randomDateBefore(Date date)
      Creates a random date that is before from the given date.
      Parameters:
      date - The date from where to compute the Past date.
      Returns:
      The random Date in the past.
    • randomDateBefore

      public static Date randomDateBefore(Date date, int range)
      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.
      Returns:
      The random Date in the past.
    • randomDateBefore

      public static Date randomDateBefore(Date date, int range, 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 Date randomDate()
      Creates a random Date
      Returns:
      The random Date
    • randomDate

      public static Date randomDate(Date from)
      Creates a random date.
      Parameters:
      from - The date from where to begin.
      Returns:
      The random date.
    • randomDate

      public static Date randomDate(Date from, 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 Date randomDate(SecureRandom secureRandom)
      Creates a random Date
      Parameters:
      secureRandom - the secure random for Date generation
      Returns:
      The random Date
    • randomDateBetween

      public static Date randomDateBetween(Date start, Date end, 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 String randomDateBetween(long startDate, long endDate, String format, 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.
    • randomDatebetween

      public static Date randomDatebetween(Date start, Date end)
      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.
      Returns:
      A random Date between the range from start and end.
    • randomDatebetween

      public static String randomDatebetween(long startDate, long endDate)
      Creates a random Date between the range from startDays and endDays from the given Date and gives it back as a string to the default "dd.MM.yyyy HH:mm:ss" format.
      Parameters:
      startDate - The date from where to start as a long.
      endDate - The date from where to end as a long.
      Returns:
      The random date as a String.
    • randomDatebetween

      public static String randomDatebetween(long startDate, long endDate, String format)
      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.
      Returns:
      The random date as a String.
    • randomDateBetween

      public static Date randomDateBetween(Date from, int startDays, int endDays)
      Creates a random Date between the range from startDays and endDays from the given Date.
      Parameters:
      from - The Date from where to the random Date to start.
      startDays - The int that represents the days from where the range starts.
      endDays - The int that represents the days from where the range ends.
      Returns:
      A random Date between the range from startDays and endDays from the given Date.
    • randomLocalDate

      public static LocalDate randomLocalDate()
      Creates a random LocalDate object
      Returns:
      the random LocalDate object
    • randomLocalDateTime

      public static LocalDateTime randomLocalDateTime()
      Creates a random LocalDateTime object
      Returns:
      the random LocalDateTime object
    • randomLocalTime

      public static LocalTime randomLocalTime()
      Creates a random LocalTime object
      Returns:
      the random LocalTime object
    • randomZoneId

      public static ZoneId randomZoneId()
      Creates a random LocalDateTime object
      Returns:
      the zone id