Java Code Examples for java.time.Instant#plusMillis()
The following examples show how to use
java.time.Instant#plusMillis() .
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: TCKInstant.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="PlusMillis") public void plusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Instant t = Instant.ofEpochSecond(seconds, nanos); t = t.plusMillis(amount); assertEquals(t.getEpochSecond(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); }
Example 2
Source File: TCKInstant.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void plusMillis_long_min() { Instant t = Instant.ofEpochSecond(MIN_SECOND, 1000000); t = t.plusMillis(-1); assertEquals(t.getEpochSecond(), MIN_SECOND); assertEquals(t.getNano(), 0); }
Example 3
Source File: TCKInstant.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void plusMillis_long_max() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 998999999); t = t.plusMillis(1); assertEquals(t.getEpochSecond(), MAX_SECOND); assertEquals(t.getNano(), 999999999); }
Example 4
Source File: TCKInstant.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="PlusMillis") public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Instant t = Instant.ofEpochSecond(seconds - 1, nanos); t = t.plusMillis(amount); assertEquals(t.getEpochSecond(), expectedSeconds - 1); assertEquals(t.getNano(), expectedNanoOfSecond); }
Example 5
Source File: TCKInstant.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void plusMillis_long_min() { Instant t = Instant.ofEpochSecond(MIN_SECOND, 1000000); t = t.plusMillis(-1); assertEquals(t.getEpochSecond(), MIN_SECOND); assertEquals(t.getNano(), 0); }
Example 6
Source File: TCKInstant.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void plusMillis_long_max() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 998999999); t = t.plusMillis(1); assertEquals(t.getEpochSecond(), MAX_SECOND); assertEquals(t.getNano(), 999999999); }
Example 7
Source File: TCKInstant.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="PlusMillis") public void plusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Instant t = Instant.ofEpochSecond(seconds + 1, nanos); t = t.plusMillis(amount); assertEquals(t.getEpochSecond(), expectedSeconds + 1); assertEquals(t.getNano(), expectedNanoOfSecond); }
Example 8
Source File: TCKInstant.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="PlusMillis") public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Instant t = Instant.ofEpochSecond(seconds - 1, nanos); t = t.plusMillis(amount); assertEquals(t.getEpochSecond(), expectedSeconds - 1); assertEquals(t.getNano(), expectedNanoOfSecond); }
Example 9
Source File: TCKInstant.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void plusMillis_long_min() { Instant t = Instant.ofEpochSecond(MIN_SECOND, 1000000); t = t.plusMillis(-1); assertEquals(t.getEpochSecond(), MIN_SECOND); assertEquals(t.getNano(), 0); }
Example 10
Source File: TCKInstant.java From j2objc with Apache License 2.0 | 5 votes |
@Test() @UseDataProvider("provider_plusMillis_long") public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Instant t = Instant.ofEpochSecond(seconds - 1, nanos); t = t.plusMillis(amount); assertEquals(t.getEpochSecond(), expectedSeconds - 1); assertEquals(t.getNano(), expectedNanoOfSecond); }
Example 11
Source File: TCKInstant.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooBig() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000); t.plusMillis(1); }
Example 12
Source File: TCKInstant.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooBig() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000); t.plusMillis(1); }
Example 13
Source File: TCKInstant.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooSmall() { Instant t = Instant.ofEpochSecond(MIN_SECOND, 0); t.plusMillis(-1); }
Example 14
Source File: TCKInstant.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooBig() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000); t.plusMillis(1); }
Example 15
Source File: TCKInstant.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooSmall() { Instant t = Instant.ofEpochSecond(MIN_SECOND, 0); t.plusMillis(-1); }
Example 16
Source File: TestDefaultPlaceExecutorRegistry.java From arcusplatform with Apache License 2.0 | 4 votes |
/** * Test case * Time firstTick) attempt to load the place returns not found * Time cachedTick) a second, very quick, request gets the same negative cache entry * Time expiredTick) a bit later a new request is made, the cache entry is expired and re-loaded, this time with data * Time recachedTick) a bit later another request is made, this time returning the same entry */ @Test public void testEnvironmentNotFoundThenFound() { Instant firstTick = Instant.now(); Instant cachedTick = firstTick.plusMillis(100); Instant expiredTick = cachedTick.plus(10, ChronoUnit.MINUTES); Instant recachedTick = expiredTick.plusMillis(100); Optional<PlaceEnvironmentExecutor> executorRef; { expectPlaceNotFound(placeId); replay(); setTime(firstTick); executorRef = registry.getExecutor(placeId); assertFalse(executorRef.isPresent()); assertTrue(registry.isCached(placeId)); setTime(cachedTick); executorRef = registry.getExecutor(placeId); assertFalse(executorRef.isPresent()); assertTrue(registry.isCached(placeId)); verify(); } reset(); { expectLoadPlace(placeId); replay(); setTime(expiredTick); executorRef = registry.getExecutor(placeId); assertTrue(executorRef.isPresent()); assertTrue(registry.isCached(placeId)); // additional access should return the same instance setTime(recachedTick); assertEquals(executorRef, registry.getExecutor(placeId)); verify(); } }
Example 17
Source File: TCKInstant.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooBig() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000); t.plusMillis(1); }
Example 18
Source File: TCKInstant.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooSmall() { Instant t = Instant.ofEpochSecond(MIN_SECOND, 0); t.plusMillis(-1); }
Example 19
Source File: TCKInstant.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void plusMillis_long_overflowTooBig() { Instant t = Instant.ofEpochSecond(MAX_SECOND, 999000000); t.plusMillis(1); }
Example 20
Source File: OutlookReader.java From sakai with Educational Community License v2.0 | 4 votes |
public List filterEvents(List events, String[] customFieldNames, String tzid) throws ImportException { ZoneId dstZoneId = ZoneId.of(getTimeService().getLocalTimeZone().getID()); ZoneId srcZoneId; if (tzid != null) { srcZoneId = ZoneId.of(tzid); } else { srcZoneId = dstZoneId; } setColumnDelimiter(","); Iterator it = events.iterator(); // // Convert the date/time fields as they appear in the Outlook import to // be a synthesized start/end timerange. // while ( it.hasNext() ) { Map eventProperties = (Map)it.next(); Date startTime = (Date) eventProperties.get(defaultHeaderMap.get(GenericCalendarImporter.START_TIME_DEFAULT_COLUMN_HEADER)); Date startDate = (Date) eventProperties.get(defaultHeaderMap.get(GenericCalendarImporter.DATE_DEFAULT_COLUMN_HEADER)); Date endTime = (Date) eventProperties.get(defaultHeaderMap.get(GenericCalendarImporter.END_TIME_DEFAULT_COLUMN_HEADER)); Date endDate = (Date) eventProperties.get(defaultHeaderMap.get(GenericCalendarImporter.ENDS_DEFAULT_COLUMN_HEADER)); if (startTime == null ) { throw new ImportException(rb.getString("err_no_stime")); } if (endTime == null ) { throw new ImportException(rb.getString("err_no_etime")); } // Raw date + raw time Instant startInstant = startTime.toInstant(); Instant endInstant = endTime.toInstant(); if (startDate != null) { startInstant = startInstant.plusMillis(startDate.getTime()); } if (endDate != null) { endInstant = endInstant.plusMillis(endDate.getTime()); } // Duration of event long duration = endInstant.toEpochMilli() - startInstant.toEpochMilli(); // Raw + calendar/owner TZ's offset ZonedDateTime srcZonedDateTime = startInstant.atZone(srcZoneId); long millis = startInstant.plusMillis(srcZonedDateTime.getOffset().getTotalSeconds() * 1000).toEpochMilli(); // Time Service will ajust to current user's TZ eventProperties.put(GenericCalendarImporter.ACTUAL_TIMERANGE, getTimeService().newTimeRange(millis, duration)); } return events; }