public class ServicesTimestampLongConverter extends Object implements LongConverter
LongConverter interface.
The class is specifically designed to convert timestamps representing service times across different
units: nanoseconds (ns), microseconds (us), and milliseconds (ms). The preferred time unit can be
specified system-wide using the 'service.time.unit' system property. If not explicitly set, the default
unit will be nanoseconds.| Modifier and Type | Field and Description |
|---|---|
static ServicesTimestampLongConverter |
INSTANCE |
| Constructor and Description |
|---|
ServicesTimestampLongConverter() |
| Modifier and Type | Method and Description |
|---|---|
void |
append(net.openhft.chronicle.bytes.Bytes<?> bytes,
long value)
Appends a representation of the provided long timestamp (in the system-configured time unit) to the provided
Bytes. |
void |
append(StringBuilder text,
long value)
Appends a representation of the provided long timestamp (in the system-configured time unit) to the provided
StringBuilder. |
static long |
currentTime()
Fetches the current time in the system-configured time unit using the default CLOCK.
|
static long |
currentTime(net.openhft.chronicle.core.time.TimeProvider clock)
Fetches the current time in the system-configured time unit using the provided TimeProvider.
|
long |
parse(CharSequence text)
Parses the provided
CharSequence into a timestamp in the configured time unit. |
long |
parse(CharSequence text,
int beginIndex,
int endIndex)
Parses a part of the provided
CharSequence using the underlying converter. |
static TimeUnit |
timeUnit()
Returns the current system-configured time unit.
|
static long |
toTime(long arg)
Converts a timestamp to the service's configured time unit.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEncode, allSafeChars, asString, asText, asText, forSymbols, lengthCheck, lengthCheck, maxParseLength, maxParseLength@UsedViaReflection public static final ServicesTimestampLongConverter INSTANCE
public static long toTime(long arg)
arg - The timestamp value, typically nanoseconds since epoch (from
System.nanoTime() or
TimeProvider.currentTimeNanos()),
to be converted to the service time unit.public static long currentTime()
public static long currentTime(net.openhft.chronicle.core.time.TimeProvider clock)
clock - The TimeProvider instance used to obtain
the current time. This allows for custom time sources, for example in tests.public static TimeUnit timeUnit()
TimeUnit.public long parse(CharSequence text)
CharSequence into a timestamp in the configured time unit.parse in interface LongConvertertext - The character sequence representing a date-time string, which will be parsed by
the underlying timestamp converter (for example
NanoTimestampLongConverter or MicroTimestampLongConverter) based
on the service time unit configuration.public long parse(CharSequence text, int beginIndex, int endIndex)
CharSequence using the underlying converter.parse in interface LongConvertertext - The character sequence containing the date-time string to parse.beginIndex - The starting index (inclusive) of the subsequence in text to be parsed.endIndex - The ending index (exclusive) of the subsequence in text to be parsed.public void append(StringBuilder text, long value)
StringBuilder.append in interface LongConvertertext - The StringBuilder to which the formatted string representation of the
timestamp value will be appended, using the service's configured time
unit and associated formatter.value - The timestamp value, in the service's configured time unit, to be formatted and
appended.public void append(net.openhft.chronicle.bytes.Bytes<?> bytes,
long value)
Bytes.append in interface LongConverterbytes - The Bytes instance to which the formatted
string representation of the timestamp value will be appended, using the
service's configured time unit and associated formatter.value - The timestamp value, in the service's configured time unit, to be formatted and
appended.Copyright © 2026 Chronicle Software Ltd. All rights reserved.