Close

Java Date Time - OffsetTime.withNano() 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 withNano(int nanoOfSecond)

Returns a copy of this OffsetTime with nano-of-second replaced with the provided 'nanoOfSecond'.


Examples


package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class WithNanoExample {

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

OffsetTime t2 = t.withNano(100);
System.out.println(t2);
}
}

Output

16:12:48.913-05:00
16:12:48.000000100-05:00




See Also