Package de.alpharogroup.random.date
Class RandomDateExtensions
- java.lang.Object
-
- de.alpharogroup.random.date.RandomDateExtensions
-
public final class RandomDateExtensions extends java.lang.ObjectThe classRandomDateExtensionsis a utility class for creating random random dates.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.DatedateAfter(java.util.Date date)Creates a random Date that is after from the given Date.static java.util.DatedateAfter(java.util.Date date, int range)Creates a random Date that is after from the given Date.static java.util.DatedateBefore(java.util.Date date)Creates a random date that is before from the given date.static java.util.DatedateBefore(java.util.Date date, int range)Creates a random date that is before from the given date.static java.util.DaterandomBirthday()Creates a random birthday-date between 9 and 55 years.static java.util.DaterandomBirthday(java.util.Date from, java.util.Date till)Creates a random birthday-date between the two given date-objects.static java.util.DaterandomDate()Creates a randomDatestatic java.util.DaterandomDate(java.util.Date from)Creates a random date.static java.util.DaterandomDate(java.util.Date from, java.security.SecureRandom secureRandom)Creates a random date.static java.lang.StringrandomDatebetween(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.static java.lang.StringrandomDatebetween(long startDate, long endDate, java.lang.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.static java.util.DaterandomDatebetween(java.util.Date start, java.util.Date end)Creates a random Date between the range from start and end.static java.util.DaterandomDateBetween(java.util.Date from, int startDays, int endDays)Creates a random Date between the range from startDays and endDays from the given Date.static java.time.LocalDaterandomLocalDate()Creates a randomLocalDateobjectstatic java.time.LocalDateTimerandomLocalDateTime()Creates a randomLocalDateTimeobjectstatic java.time.LocalTimerandomLocalTime()Creates a randomLocalTimeobjectstatic java.time.ZoneIdrandomZoneId()Creates a randomLocalDateTimeobject
-
-
-
Method Detail
-
dateAfter
public static java.util.Date dateAfter(java.util.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.
-
dateAfter
public static java.util.Date dateAfter(java.util.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.
-
dateBefore
public static java.util.Date dateBefore(java.util.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.
-
dateBefore
public static java.util.Date dateBefore(java.util.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.
-
randomBirthday
public static java.util.Date randomBirthday()
Creates a random birthday-date between 9 and 55 years.- Returns:
- 's the random date.
-
randomBirthday
public static java.util.Date randomBirthday(java.util.Date from, java.util.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.
-
randomDate
public static java.util.Date randomDate()
Creates a randomDate- Returns:
- The random
Date
-
randomDate
public static java.util.Date randomDate(java.util.Date from)
Creates a random date.- Parameters:
from- The date from where to begin.- Returns:
- The random date.
-
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.
-
randomDatebetween
public static java.util.Date randomDatebetween(java.util.Date start, java.util.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 java.lang.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 java.lang.String randomDatebetween(long startDate, long endDate, java.lang.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 java.util.Date randomDateBetween(java.util.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 java.time.LocalDate randomLocalDate()
Creates a randomLocalDateobject- Returns:
- the random
LocalDateobject
-
randomLocalDateTime
public static java.time.LocalDateTime randomLocalDateTime()
Creates a randomLocalDateTimeobject- Returns:
- the random
LocalDateTimeobject
-
randomLocalTime
public static java.time.LocalTime randomLocalTime()
Creates a randomLocalTimeobject- Returns:
- the random
LocalTimeobject
-
randomZoneId
public static java.time.ZoneId randomZoneId()
Creates a randomLocalDateTimeobject- Returns:
- the zone id
-
-