de.skuzzle.test.snapshots.normalize.Generators Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snapshot-tests-normalize Show documentation
Show all versions of snapshot-tests-normalize Show documentation
Travers/Clean/Normalize object instances
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