I'm testing an example from here. But getting this error incompatible types: long cannot be converted to Instant
.
Code:
import java.time.Instant;
import java.time.temporal.Temporal;
import java.time.temporal.ChronoUnit;
class HelloWorld {
public static void main(String[] args) {
Instant previous = Instant.parse("2022-04-16T08:03:50.054341Z"), current, gap;
current = Instant.now();
if (previous != null) {
gap = ChronoUnit.MILLIS.between(previous,current);
}
System.out.println("Hello, World! "+current+ " , "+previous + " , "+gap);
}
}