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

de.skuzzle.test.snapshots.normalize.Generators Maven / Gradle / Ivy

There is a newer version: 1.11.0
Show newest version
package de.skuzzle.test.snapshots.normalize;

import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.function.BiFunction;

public class Generators {

    public static BiFunction uuidLike() {
        return (i, match) -> {
            final String hex = Integer.toHexString(i);
            return "00000000-0000-0000-0000-" + "0".repeat(12 - hex.length()) + hex;
        };
    }

    public static BiFunction dateLike(DateTimeFormatter formatter) {
        return (i, match) -> {
            final long millis = 365L * 24L * 60L * 60L * 1000L * (long) i;
            final ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.UTC);
            return formatter.format(zonedDateTime);
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy