Java Code Examples for java.time.Instant#atOffset()
The following examples show how to use
java.time.Instant#atOffset() .
These examples are extracted from open source projects.
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 Project: dragonwell8_jdk File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 2
Source Project: TencentKona-8 File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 3
Source Project: jdk8u60 File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 4
Source Project: catnip File: Utils.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nonnull @CheckReturnValue public static OffsetDateTime creationTimeOf(final long id) { final long discordTimestamp = id >> 22; final Instant instant = Instant.ofEpochMilli(discordTimestamp + DISCORD_EPOCH); return instant.atOffset(ZoneOffset.UTC); }
Example 5
Source Project: openjdk-jdk8u File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 6
Source Project: openjdk-jdk8u-backup File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 7
Source Project: openjdk-jdk9 File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 8
Source Project: jdk8u-jdk File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 9
Source Project: hottub File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 10
Source Project: openjdk-8-source File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 11
Source Project: openjdk-8 File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 12
Source Project: jdk8u_jdk File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 13
Source Project: jdk8u-jdk File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 14
Source Project: jdk8u-dev-jdk File: TCKInstant.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 15
Source Project: j2objc File: TCKInstant.java License: Apache License 2.0 | 5 votes |
@Test public void test_atOffset() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1)); assertEquals(test.getYear(), 1970); assertEquals(test.getMonthValue(), 1); assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); } }
Example 16
Source Project: docker-compose-rule File: EventEmitterShould.java License: Apache License 2.0 | 4 votes |
private OffsetDateTime timeIs(int seconds) { Instant instant = Instant.ofEpochSecond(seconds); when(clock.instant()).thenReturn(instant); return instant.atOffset(ZoneOffset.UTC); }
Example 17
Source Project: java-timeseries File: TimeSpec.java License: MIT License | 4 votes |
@Test public void whenToInstantThenCorrectInstantReturned() { Instant instant = Instant.ofEpochSecond(3000L); Time time = new Time(instant.atOffset(ZoneOffset.UTC)); assertThat(time.toInstant(), is(instant)); }
Example 18
Source Project: ShedLock File: Utils.java License: Apache License 2.0 | 4 votes |
public static String toIsoString(@NonNull Instant instant) { OffsetDateTime utc = instant.atOffset(ZoneOffset.UTC); return formatter.format(utc); }
Example 19
Source Project: cloudformation-cli-java-plugin File: CronHelper.java License: Apache License 2.0 | 3 votes |
/** * Schedule a re-invocation of the executing handler no less than 1 minute from * now * * * /** Creates a cron(..) expression for a single instance at Now+minutesFromNow * NOTE: CloudWatchEvents only support a 1minute granularity for re-invoke * Anything less should be handled inside the original handler request * * Expression is of form cron(minutes, hours, day-of-month, month, day-of-year, * year) where day-of-year is not necessary when the day-of-month and * month-of-year fields are supplied * * @param minutesFromNow The number of minutes from now for building the cron * expression * @return A cron expression for use with CloudWatchEvents putRule(..) API */ public String generateOneTimeCronExpression(final int minutesFromNow) { // Add additional 1 minute, since rule can be created after scheduled time, like // "13:40:59" -> cron(41 13 30) Instant instant = Instant.now(this.clock).plusSeconds(60L * (minutesFromNow + 1)); OffsetDateTime odt = instant.atOffset(ZoneOffset.UTC); return DateTimeFormatter.ofPattern("'cron('m H d M ? u')'").format(odt); }