Package biz.onixs.util
Class HighResolutionTimestamp
- java.lang.Object
-
- biz.onixs.util.HighResolutionTimestamp
-
- All Implemented Interfaces:
Comparable<HighResolutionTimestamp>
public class HighResolutionTimestamp extends Object implements Comparable<HighResolutionTimestamp>
High resolution timestamp containing timestamp with millisecond precision and high resolution component with picoseconds precision.
-
-
Constructor Summary
Constructors Constructor Description HighResolutionTimestamp()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassemble(byte[] buffer, int offset, TimestampFormat format)Assemble high resolution timestamp into specified buffer from specified offset with corresponding format.intcompareTo(HighResolutionTimestamp o)booleanequals(Object obj)LocalDateTimegetLocalDateTime()Returns timestamp without high resolution component of the high resolution timestamp.longgetPicoSecond()Returns picosecond component of the high resolution timestamp.voidparse(byte[] buffer, int offset, int length, TimestampFormat format)Parses timestamp from byte array.voidsetLocalDateTime(LocalDateTime localDateTime)Sets timestamp without high resolution component of the high resolution timestamp.voidsetPicoSecond(long picoSecond)Sets picosecond component of the high resolution timestamp.StringtoString()booleantryParse(byte[] buffer, int offset, int length, TimestampFormat format)Tries to parse timestamp from byte array.
-
-
-
Method Detail
-
getLocalDateTime
public LocalDateTime getLocalDateTime()
Returns timestamp without high resolution component of the high resolution timestamp.- Returns:
- timestamp without high resolution component of the high resolution timestamp
-
setLocalDateTime
public void setLocalDateTime(LocalDateTime localDateTime)
Sets timestamp without high resolution component of the high resolution timestamp.- Parameters:
localDateTime- timestamp without high resolution component to be set
-
getPicoSecond
public long getPicoSecond()
Returns picosecond component of the high resolution timestamp.- Returns:
- picosecond component of the high resolution timestamp
-
setPicoSecond
public void setPicoSecond(long picoSecond)
Sets picosecond component of the high resolution timestamp.- Parameters:
picoSecond- picoseconds to be set
-
parse
public void parse(byte[] buffer, int offset, int length, TimestampFormat format) throws ParseExceptionParses timestamp from byte array.- Parameters:
buffer- source bufferoffset- offset in the source bufferlength- length of the value in the source bufferformat- timestamp format to be parsed- Throws:
NullPointerException- if(null == buffer)or(null == format)IllegalArgumentException- if(offset < 0)or(offset + length > buffer.length)ParseException- if byte array can not be parsed with specified format
-
tryParse
public boolean tryParse(byte[] buffer, int offset, int length, TimestampFormat format)Tries to parse timestamp from byte array.- Parameters:
buffer- source bufferoffset- offset in the source bufferlength- length of the value in the source bufferformat- timestamp format to be parsed- Returns:
trueif timestamp successfully parsed,falseotherwise.- Throws:
NullPointerException- if(null == buffer)or(null == format)IllegalArgumentException- if(offset < 0)or(offset + length > buffer.length)
-
assemble
public void assemble(byte[] buffer, int offset, TimestampFormat format)Assemble high resolution timestamp into specified buffer from specified offset with corresponding format.- Parameters:
buffer- buffer to be used for assembleoffset- offset in the buffer to be usedformat- format to be used for assemble- Throws:
NullPointerException- if(null == buffer)or(null == format)IllegalArgumentException- if(offset + [format length] > buffer.length)
-
compareTo
public int compareTo(HighResolutionTimestamp o)
- Specified by:
compareToin interfaceComparable<HighResolutionTimestamp>
-
-