Java Code Examples for java.time.LocalDateTime#minusNanos()
The following examples show how to use
java.time.LocalDateTime#minusNanos() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKLocalDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 2
Source File: TCKLocalDateTime.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 3
Source File: TCKLocalDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 4
Source File: TCKLocalDateTime.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 5
Source File: TCKLocalDateTime.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 6
Source File: TCKLocalDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 7
Source File: TCKLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 8
Source File: TCKLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 9
Source File: TCKLocalDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 10
Source File: TCKLocalDateTime.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 11
Source File: TCKLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 12
Source File: TCKLocalDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 13
Source File: TCKLocalDateTime.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 14
Source File: TCKLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 15
Source File: TestITCHMessageCreator.java From sailfish-core with Apache License 2.0 | 5 votes |
public IMessage getTestDate() throws ParseException{ IMessage message = messageHelper.getMessageFactory().createMessage("testDate", "ITCH"); String dateString = "20160627"; String timeString = "10:10:11"; TimeZone timeZone = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyyMMdd"); df.setTimeZone(timeZone); DateFormat tf = new SimpleDateFormat("HH:mm:ss"); tf.setTimeZone(timeZone); Date startDate=df.parse(dateString); Date startTime=tf.parse(timeString); Date days = new Date(100); LocalDateTime localDays = DateTimeUtility.toLocalDateTime(days); localDays = localDays.minusNanos(localDays.getNano()); message.addField("Date", DateTimeUtility.toLocalDate(startDate)); message.addField("Time", DateTimeUtility.toLocalTime(startTime)); message.addField("Days", DateTimeUtility.toLocalDate(startDate)); message.addField("STUB", DateTimeUtility.toLocalDateTime(days)); DateTimeFormatter extTimeFormatter = DateTimeUtility.createFormatter("HH:mm:ss.SSS"); LocalTime extTime = LocalTime.parse("10:10:11.123", extTimeFormatter); message.addField("ExtTime", extTime); DateTimeFormatter dateTimeFormatter = DateTimeUtility.createFormatter("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"); ZonedDateTime zonedDateTime = DateTimeUtility.toZonedDateTime(dateTimeFormatter.parse("2019-12-31T01:02:03.123456Z")); message.addField("Date_Time", DateTimeUtility.toLocalDateTime(zonedDateTime)); // LocalDateTime localDays = DateTimeUtility.toLocalDateTime(100); // localDays = localDays.minusNanos(localDays.getNano()); // message.addField("Date", DateTimeUtility.toLocalDateTime(startDate)); // message.addField("Time", DateTimeUtility.toLocalDateTime(startTime)); // message.addField("Days", localDays); // message.addField("STUB", DateTimeUtility.toLocalDateTime(100)); return messageHelper.prepareMessageToEncode(message, null); }
Example 16
Source File: TCKLocalDateTime.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }
Example 17
Source File: TCKLocalDateTime.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 18
Source File: TCKLocalDateTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 19
Source File: TCKLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); int hour = 0; int min = 0; int sec = 0; int nanos = 0; for (long i = 0; i < 3700 * 1000000000L; i+= 500000000) { t = t.minusNanos(500000000); nanos -= 500000000; if (nanos < 0) { sec--; nanos += 1000000000; if (sec == -1) { min--; sec += 60; if (min == -1) { hour--; min += 60; if (hour == -1) { hour += 24; } } } } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); assertEquals(t.getNano(), nanos); } }
Example 20
Source File: TCKLocalDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); assertEquals(date, t.toLocalDate()); assertEquals(hour, t.getHour()); assertEquals(min, t.getMinute()); assertEquals(sec, t.getSecond()); assertEquals(nanos, t.getNano()); }