下面列出了java.time.OffsetDateTime#withNano ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
@Test
public void test_withNanoOfSecond_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(1);
assertSame(test, base);
}
/**
* Get the passed date time but with micro and nanoseconds set to 0, so that
* only the milliseconds part is present. This is helpful for XSD
* serialization, where only milliseconds granularity is available.
*
* @param aODT
* Source date time. May be <code>null</code>.
* @return <code>null</code> if the parameter is <code>null</code>, the local
* date time with microseconds and nanoseconds set to 0 otherwise.
* @since 9.2.0
*/
@Nullable
public static OffsetDateTime getWithMillisOnly (@Nullable final OffsetDateTime aODT)
{
return aODT == null ? null : aODT.withNano (aODT.get (ChronoField.MILLI_OF_SECOND) *
(int) CGlobal.NANOSECONDS_PER_MILLISECOND);
}