Search code examples
javaintegerepoch

How to use epoch time of nanoseconds in Java?


I have to send a message with current time(EPOCH) of the system and which will be sending according to following details. Also EPOCH time send in nanoseconds.

field - current_time
type - UINT64
byte size - 8
value - 0 to 1.84467E+19

My message structure is as below,

class MsgHeader {
   int message_length;
   String sender_sys;
   String destination_sys;
   **int current_time;**
   char message_type;

................

}

could anyone please suggest me how to do this using java?


Solution

  • long current_time = System.currentTimeMillis() * 1_000_000L;