Java Date Time Java Java API
java.time.OffsetDateTime
public OffsetDateTime withNano(int nanoOfSecond)
Returns a copy of this OffsetDateTime with nano-of-second replaced with the provided 'nanoOfSecond'.
package com.logicbig.example.offsetdatetime;import java.time.OffsetDateTime;import java.time.ZoneOffset;public class WithNanoExample { public static void main(String... args) { OffsetDateTime d = OffsetDateTime.of(2015, 10, 5, 15, 30, 10, 1000000, ZoneOffset.ofHours(-5)); System.out.println(d); OffsetDateTime d2 = d.withNano(150000); System.out.println(d2); }}
2015-10-05T15:30:10.001-05:002015-10-05T15:30:10.000150-05:00