Closed nimo23 closed 3 years ago
When COMB generators were implemented, the extraction methods were left to be implemented in the future. I wasn't sure if anyone was going to need it.
I just released version 3.5.0. The following methods are now available:
CombUtil.extractPrefix()
: returns the unix millis from Prefix COMBs;CombUtil.extractSuffix()
: returns the unix millis from Suffix COMBs;CombUtil.extractPrefixInstant()
: // returns the instant from Prefix COMBs;CombUtil.extractSuffixInstant()
: // returns the instant from Suffix COMBs.No extraction method was implemented for Short Prefix COMBs and Short Suffix COMBs.
Now to extract the Instant you can do this:
String combString = UuidCreator.getPrefixComb().toString();
StringCodec codec = new StringCodec(); // initialize the canonical string codec
UUID comb = codec.decode(combString); // decode the comb string
Instant instant = CombUtil.extractPrefixInstant(comb); // extract the instant
One question:
How can I get the Instant from a comb which comes from a String?
var combString = UuidCreator.getPrefixComb().toString();
There is a
UuidUtil.extractInstant()
,UlidUtil.extractInstant()
, but noCombUtil.extractInstant()
.