Java Date Time - LocalTime plusNanos(long nanosToAdd) example








LocalTime plusNanos(long nanosToAdd) returns a copy of this LocalTime with the specified period in nanoseconds added.

Syntax

plusNanos has the following syntax.

public LocalTime plusNanos(long nanosToAdd)

Example

The following example shows how to use plusNanos.

import java.time.LocalTime;

public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.plusNanos(1234);
    System.out.println(s);
  }
}

The code above generates the following result.