All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.javarig.generator.LocalDateGenerator Maven / Gradle / Ivy

Go to download

This project aims to provide a random instances generator for any class in java, it iterates through setters of an empty object and sets the fields values (using Java reflection api) randomly

The newest version!
package io.javarig.generator;

import io.javarig.RandomInstanceGenerator;

import java.lang.reflect.Type;
import java.time.Instant;
import java.time.LocalDate;

import static java.time.ZoneOffset.UTC;

public class LocalDateGenerator extends TypeGenerator {
    public LocalDateGenerator(Type type, RandomInstanceGenerator randomInstanceGenerator) {
        super(type, randomInstanceGenerator);
    }

    @Override
    public LocalDate generate() {
        return ((Instant) getRandomInstanceGenerator().generate(Instant.class)).atZone(UTC).toLocalDate();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy