Class ToEpochTimeUUID
- java.lang.Object
-
- io.virtdata.libbasics.shared.from_long.to_time_types.ToEpochTimeUUID
-
- All Implemented Interfaces:
java.util.function.LongFunction<java.util.UUID>
public class ToEpochTimeUUID extends java.lang.Object implements java.util.function.LongFunction<java.util.UUID>Converts a long UTC timestamp in epoch millis form into a Version 1 TimeUUID according to RFC 4122. This means that only one unique value for a timeuuid can be generated for each epoch milli value, even though version 1 TimeUUIDs can normally represent up to 10000 distinct values per millisecond. If you need to access this level of resolution for testing purposes, useToFinestTimeUUIDinstead. This method is to support simple mapping to natural timestamps as we often find in the real world.For the variants that have a String argument in the constructor, this is a parsable datetime that is used as the base time for all produced values. Setting this allows you to set the start of the time range for all timeuuid values produced. All times are parsed for UTC. All time use ISO date ordering, meaning that the most significant fields always go before the others.
The valid formats, in joda specifier form are:
- yyyy-MM-dd HH:mm:ss.SSSZ, for example: 2015-02-28 23:30:15.223
- yyyy-MM-dd HH:mm:ss, for example 2015-02-28 23:30:15
- yyyyMMdd'T'HHmmss.SSSZ, for example: 20150228T233015.223
- yyyyMMdd'T'HHmmssZ, for example: 20150228T233015
- yyyy-MM-dd, for example: 2015-02-28
- yyyyMMdd, for example: 20150228
- yyyyMM, for example: 201502
- yyyy, for example: 2015
-
-
Constructor Summary
Constructors Constructor Description ToEpochTimeUUID()Create version 1 timeuuids with a per-host node and empty clock data.ToEpochTimeUUID(long node)Create version 1 timeuuids with a specific static node and empty clock data.ToEpochTimeUUID(long node, long clock)Create version 1 timeuuids with a specific static node and specific clock data.ToEpochTimeUUID(java.lang.String baseSpec)Create version 1 timeuuids with a per-host node and empty clock data.ToEpochTimeUUID(java.lang.String baseSpec, long node)Create version 1 timeuuids with a specific static node and empty clock data.ToEpochTimeUUID(java.lang.String baseSpec, long node, long clock)Create version 1 timeuuids with a specific static node and specific clock data.
-
Method Summary
Modifier and Type Method Description java.util.UUIDapply(long timeTicks)
-
-
-
Constructor Detail
-
ToEpochTimeUUID
public ToEpochTimeUUID()
Create version 1 timeuuids with a per-host node and empty clock data. The node and clock components are seeded from network interface data. In this case, the clock data is not seeded uniquely.
-
ToEpochTimeUUID
public ToEpochTimeUUID(long node)
Create version 1 timeuuids with a specific static node and empty clock data. This is useful for testing so that you can know that values are verifiable, even though in non-testing practice, you would rely on some form of entropy per-system to provide more practical dispersion of values over reboots, etc.- Parameters:
node- a fixture value for testing that replaces node and clock bits
-
ToEpochTimeUUID
public ToEpochTimeUUID(long node, long clock)Create version 1 timeuuids with a specific static node and specific clock data. This is useful for testing so that you can know that values are verifiable, even though in non-testing practice, you would rely on some form of entropy per-system to provide more practical dispersion of values over reboots, etc.- Parameters:
node- a fixture value for testing that replaces node bitsclock- a fixture value for testing that replaces clock bits
-
ToEpochTimeUUID
public ToEpochTimeUUID(java.lang.String baseSpec)
Create version 1 timeuuids with a per-host node and empty clock data. The node and clock components are seeded from network interface data. In this case, the clock data is not seeded uniquely.- Parameters:
baseSpec- - a string specification for the base time value
-
ToEpochTimeUUID
public ToEpochTimeUUID(java.lang.String baseSpec, long node)Create version 1 timeuuids with a specific static node and empty clock data. This is useful for testing so that you can know that values are verifiable, even though in non-testing practice, you would rely on some form of entropy per-system to provide more practical dispersion of values over reboots, etc.- Parameters:
baseSpec- - a string specification for the base time valuenode- a fixture value for testing that replaces node and clock bits
-
ToEpochTimeUUID
public ToEpochTimeUUID(java.lang.String baseSpec, long node, long clock)Create version 1 timeuuids with a specific static node and specific clock data. This is useful for testing so that you can know that values are verifiable, even though in non-testing practice, you would rely on some form of entropy per-system to provide more practical dispersion of values over reboots, etc.- Parameters:
baseSpec- - a string specification for the base time valuenode- a fixture value for testing that replaces node bitsclock- a fixture value for testing that replaces clock bits
-
-