Close

Java Date Time - ZonedDateTime.withNano() Examples

Java Date Time Java Java API 


Class:

java.time.ZonedDateTime

java.lang.Objectjava.lang.Objectjava.time.ZonedDateTimejava.time.ZonedDateTimejava.time.temporal.TemporalTemporaljava.time.chrono.ChronoZonedDateTimeChronoZonedDateTimejava.io.SerializableSerializableLogicBig

Method:

public ZonedDateTime withNano(int nanoOfSecond)

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

Examples


package com.logicbig.example.zoneddatetime;

import java.time.ZoneId;
import java.time.ZonedDateTime;

public class WithNanoExample {

public static void main(String... args) {
ZonedDateTime d = ZonedDateTime.of(2017, 2, 12, 20, 33, 23, 10000,
ZoneId.systemDefault());
System.out.println(d);

ZonedDateTime d2 = d.withNano(0);
System.out.println(d2);
}
}

Output

2017-02-12T20:33:23.000010-06:00[America/Chicago]
2017-02-12T20:33:23-06:00[America/Chicago]




See Also