java.lang.Object
me.ahoo.cosid.codec.Friendly
- All Implemented Interfaces:
IdCodec
Encodes a time-based id as readable text,
yyyyMMddHHmmssSSS-<node>-<seq>, from Layout.unpack(long);
the time zone is always explicit (03-core-model.md ยง1). Formats through precomputed field widths into a
char[], without DateTimeFormatter.
The text holds a local time without its offset. In a zone with daylight saving time, the hour repeated when the
clocks go back reads twice: decode(String) resolves it to the earlier instant (as ZonedDateTime.of
does, and as 4.x did), so ids of the later pass through that hour do not round-trip. Use UTC or a fixed-offset zone
when ids must decode exactly.
-
Method Details
-
of
A friendly codec.- Parameters:
layout- the layout of the idszone- the time zone of the time partpadStart- whether the node and sequence parts are padded with leading zeros- Returns:
- the codec
- Throws:
IllegalArgumentException- if the layout is wider than 63 bits: usePartsCodec.friendly(me.ahoo.cosid.time.Layout, java.time.ZoneId)
-
layout
-
zone
-
padStart
public boolean padStart() -
encode
Description copied from interface:IdCodecEncodes an id (R1-core-16). -
decode
Description copied from interface:IdCodecDecodes text produced byIdCodec.encode(long).
-