Close

Java Date Time - OffsetTime.plusNanos() Examples

Java Date Time Java Java API 


Class:

java.time.OffsetTime

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

Method:

public OffsetTime plusNanos(long nanos)


Examples


package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class PlusNanosExample {

public static void main(String... args) {
OffsetTime t = OffsetTime.now();
System.out.println(t);

OffsetTime t2 = t.plusNanos(1000);
System.out.println(t2);

OffsetTime t3 = t.plusNanos(600000000L);
System.out.println(t3);
}
}

Output

16:13:16.151-05:00
16:13:16.151001-05:00
16:13:16.751-05:00




package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class PlusNanosExample2 {

public static void main(String... args) {
OffsetTime t = OffsetTime.now();
System.out.println(t);

OffsetTime t2 = t.plusNanos(-1000);
System.out.println(t2);

OffsetTime t3 = t.plusNanos(-600000000L);
System.out.println(t3);
}
}

Output

16:13:18.175-05:00
16:13:18.174999-05:00
16:13:17.575-05:00




See Also