Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

random years java

import java.time.LocalDate;

public class RandomDates {
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            LocalDate randomDate = createRandomDate(1900, 2000);
            System.out.println(randomDate);
        }
    }

    public static int createRandomIntBetween(int start, int end) {
        return start + (int) Math.round(Math.random() * (end - start));
    }

    public static LocalDate createRandomDate(int startYear, int endYear) {
        int day = createRandomIntBetween(1, 28);
        int month = createRandomIntBetween(1, 12);
        int year = createRandomIntBetween(startYear, endYear);
        return LocalDate.of(year, month, day);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: verificar numero par ou impar jacva 
Java :: multipleQuastion.Java 
Java :: convertBirthDay java 
Java :: treeset order in java 
Java :: uncaught error java.net.sockettimeoutexception failed to connect 
Java :: How To Export Records From JTable To MS Excel 
Java :: change button background drawable in code 
Java :: set attribute java 
Java :: java secureRandom certain range 
Java :: Java program to find largest of three numbers using nested if 
Java :: linked list introduction 
Java :: how to code the overdraft limit in Java 
Java :: getcokor from drawable in java android studio 
Java :: binary search 2D java 
Java :: java formatted string input 
Java :: spring environment null pointer exception 
Java :: java inetaddress workaround how to get localhost secure 
Java :: When different programmers write the same program in differing ways and all get the correct result. what is that known as? 
Java :: 111111000 
Java :: Pattern using recursion in Java 
Java :: hibernate getList of a table 
Java :: Armstrong Numbers Between Two Integers 
Java :: RedisCacheManager json serializer 
Java :: javafx treeview directory 
Java :: contoh object dalam oop java 
Java :: Rotate Vector by an angle 
Java :: remove part of string java 
Java :: extend vs implement in java 
Java :: palindrome in java 
Java :: directory size java 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =