public class RandomDateExtensions
extends java.lang.Object
RandomDateExtensions is a utility class for creating random random dates.| Constructor and Description |
|---|
RandomDateExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Date |
dateAfter(java.util.Date date)
Creates a random Date that is after from the given Date.
|
static java.util.Date |
dateAfter(java.util.Date date,
int range)
Creates a random Date that is after from the given Date.
|
static java.util.Date |
dateBefore(java.util.Date date)
Creates a random date that is before from the given date.
|
static java.util.Date |
dateBefore(java.util.Date date,
int range)
Creates a random date that is before from the given date.
|
static java.sql.Timestamp |
getTimestamp()
Creates a java.sql.Timestamp from now.
|
static java.sql.Timestamp |
getTimestamp(java.util.Date date)
Creates a java.sql.Timestamp(to match the ones in the database) from the given date.
|
static java.util.Date |
randomBirthday()
Creates a random birthday-date between 9 and 55 years.
|
static java.util.Date |
randomBirthday(java.util.Date from,
java.util.Date till)
Creates a random birthday-date between the two given date-objects.
|
static java.util.Date |
randomDate()
Creates a random
Date |
static java.util.Date |
randomDate(java.util.Date from)
Creates a random date.
|
static java.util.Date |
randomDatebetween(java.util.Date start,
java.util.Date end)
Creates a random Date between the range from start and end.
|
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.
|
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.
|
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.
|
static java.time.LocalDate |
randomLocalDate()
Creates a random
LocalDate object |
static java.time.LocalDateTime |
randomLocalDateTime()
Creates a random
LocalDateTime object |
static java.time.LocalTime |
randomLocalTime()
Creates a random
LocalTime object |
static java.time.ZoneId |
randomZoneId()
Creates a random
LocalDateTime object |
public static java.util.Date dateAfter(java.util.Date date)
date - The Date from where to compute the future date.public static java.time.ZoneId randomZoneId()
LocalDateTime objectpublic static java.time.LocalDateTime randomLocalDateTime()
LocalDateTime objectLocalDateTime objectpublic static java.time.LocalTime randomLocalTime()
LocalTime objectLocalTime objectpublic static java.time.LocalDate randomLocalDate()
LocalDate objectLocalDate objectpublic static java.util.Date dateAfter(java.util.Date date,
int range)
date - The Date from where to compute the future date.range - The range.public static java.util.Date dateBefore(java.util.Date date)
date - The date from where to compute the Past date.public static java.util.Date dateBefore(java.util.Date date,
int range)
date - The date from where to compute the past date.range - The range.public static java.sql.Timestamp getTimestamp()
public static java.sql.Timestamp getTimestamp(java.util.Date date)
date - The datepublic static java.util.Date randomBirthday()
public static java.util.Date randomBirthday(java.util.Date from,
java.util.Date till)
from - The date from where to start.till - The date from where to end.public static java.util.Date randomDate(java.util.Date from)
from - The date from where to begin.public static java.util.Date randomDate()
DateDatepublic static java.util.Date randomDatebetween(java.util.Date start,
java.util.Date end)
start - The Date from where the range starts.end - The Date from where the range ends.public static java.lang.String randomDatebetween(long startDate,
long endDate)
startDate - The date from where to start as a long.endDate - The date from where to end as a long.public static java.lang.String randomDatebetween(long startDate,
long endDate,
java.lang.String format)
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.public static java.util.Date randomDateBetween(java.util.Date from,
int startDays,
int endDays)
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.