Java Date Time Java Java API
java.time.LocalTime
public LocalTime minusNanos(long nanosToSubtract)
Returns a copy of this LocalTime with the specified number of nanoseconds subtracted, adjusting other fields if necessary.
package com.logicbig.example.localtime;import java.time.LocalTime;public class MinusNanosExample { public static void main (String... args) { LocalTime d1 = LocalTime.of(12, 30, 50, 100000); System.out.println(d1); LocalTime d2 = d1.minusNanos(5000); System.out.println(d2); d2 = d1.minusNanos(-5000); System.out.println(d2); }}
12:30:50.00010012:30:50.00009512:30:50.000105