Let us first set an Instant:
Instant now = Instant.ofEpochMilli(184142540078l);
Let us now minus seconds from Instant:
Instant resSeconds = now.minusSeconds(50);
Let us now minus nanoseconds from Instant:
Instant resNanoSeconds = now.minusNanos(10000);
import java.time.Instant; public class Demo { public static void main(String[] args) { Instant now = Instant.ofEpochMilli(184142540078l); System.out.println(now); Instant resSeconds = now.minusSeconds(50); System.out.println("After subtracting seconds = "+resSeconds); Instant resNanoSeconds = now.minusNanos(10000); System.out.println("After subtracting nanoseconds = "+resNanoSeconds); } }
1975-11-02T06:42:20.078Z After subtracting seconds = 1975-11-02T06:41:30.078Z After subtracting nanoseconds = 1975-11-02T06:42:20.077990Z