Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

randpm years java

long aDay = TimeUnit.DAYS.toMillis(1);
long now = new Date().getTime();
Date hundredYearsAgo = new Date(now - aDay * 365 * 100);
Date tenDaysAgo = new Date(now - aDay * 10);
Date random = LegacyRandomDateTimes.between(hundredYearsAgo, tenDaysAgo);
assertThat(random).isBetween(hundredYearsAgo, tenDaysAgo);
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #randpm #years #java
ADD COMMENT
Topic
Name
4+2 =