Close

Java Date Time - LocalTime.plusNanos() Examples

Java Date Time Java Java API 


Class:

java.time.LocalTime

java.lang.Objectjava.lang.Objectjava.time.LocalTimejava.time.LocalTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public LocalTime plusNanos(long nanosToAdd)

Returns a copy of this LocalTime with the specified number of nano-seconds added.



Examples


package com.logicbig.example.localtime;

import java.time.LocalTime;

public class PlusNanosExample {

public static void main (String... args) {
LocalTime t = LocalTime.of(10, 2, 20);
System.out.println(t);

LocalTime t2 = t.plusNanos(20000);
System.out.println(t2);

t2 = t.plusNanos(-20000);
System.out.println(t2);
}
}

Output

10:02:20
10:02:20.000020
10:02:19.999980




See Also