Reputation: 54
I am trying to convert hex string "07e4070e04032b
" to date and below is my code:
String hexmillis1 = "07e4070e04032b";
long convertedMillis1 = Long.decode("0x" + hexmillis1);
Instant instant1 = Instant.ofEpochMilli(convertedMillis1);
LocalDateTime localDateTime1 = LocalDateTime.ofInstant(instant1, ZoneId.systemDefault());
System.out.println(localDateTime1.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
Output: +72352-01-29T13:17:02.571
Expected output is a date and time earlier today, so 2020-07-14 or perhaps 2020-07-13.
I have tried few other ways also but it does not seem to give correct date.
The hex string is coming from a SNMP trap. Not sure of how it was exactly encoded.
Upvotes: -1
Views: 529