當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalTime.plusMinutes方法代碼示例

本文整理匯總了Java中java.time.LocalTime.plusMinutes方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalTime.plusMinutes方法的具體用法?Java LocalTime.plusMinutes怎麽用?Java LocalTime.plusMinutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.plusMinutes方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFutureEvent

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Set up an event to hang the bets off  
 */
public default void createFutureEvent() {
    // Grab some horses to use as runners in races
    final IMap<Horse, Object> fromHC = getClient().getMap("winners");
    final Set<Horse> horses = fromHC.keySet();

    // Now set up some future-dated events for next Sat
    final LocalDate nextSat = LocalDate.now().with(TemporalAdjusters.next(DayOfWeek.SATURDAY));
    LocalTime raceTime = LocalTime.of(11, 0); // 1100 start
    final Event e = CentralFactory.eventOf("Racing from Epsom", nextSat);
    final Set<Horse> runners = makeRunners(horses, 10);
    for (int i = 0; i < 18; i++) {
        final Map<Horse, Double> runnersWithOdds = makeSimulatedOdds(runners);
        final Race r = CentralFactory.raceOf(LocalDateTime.of(nextSat, raceTime), runnersWithOdds);
        e.addRace(r);

        raceTime = raceTime.plusMinutes(10);
    }
    final IMap<Long, Event> events = getClient().getMap("events");
    events.put(e.getID(), e);
}
 
開發者ID:hazelcast,項目名稱:betleopard,代碼行數:24,代碼來源:RandomSimulationUtils.java

示例2: test_plusMinutes_fromZero

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_plusMinutes_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(1);
    LocalTime t = LocalTime.of(22, 49);

    for (int i = -70; i < 70; i++) {
        LocalDateTime dt = base.plusMinutes(i);
        t = t.plusMinutes(1);

        if (t.equals(LocalTime.MIDNIGHT)) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d, String.valueOf(i));
        assertEquals(dt.toLocalTime(), t, String.valueOf(i));
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:TCKLocalDateTime.java

示例3: test_minusMinutes_fromZero

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_minusMinutes_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(1);
    LocalTime t = LocalTime.of(22, 49);

    for (int i = 70; i > -70; i--) {
        LocalDateTime dt = base.minusMinutes(i);
        t = t.plusMinutes(1);

        if (t.equals(LocalTime.MIDNIGHT)) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:TCKLocalDateTime.java

示例4: test_plusMinutes_one

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_plusMinutes_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    int hour = 0;
    int min = 0;
    for (int i = 0; i < 70; i++) {
        t = t.plusMinutes(1);
        min++;
        if (min == 60) {
            hour++;
            min = 0;
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:TCKLocalTime.java

示例5: test_plusMinutes_fromZero

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_plusMinutes_fromZero() {
    LocalTime base = LocalTime.MIDNIGHT;
    int hour;
    int min;
    for (int i = -70; i < 70; i++) {
        LocalTime t = base.plusMinutes(i);
        if (i < -60) {
            hour = 22;
            min = i + 120;
        } else if (i < 0) {
            hour = 23;
            min = i + 60;
        } else if (i >= 60) {
            hour = 1;
            min = i - 60;
        } else {
            hour = 0;
            min = i;
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:TCKLocalTime.java

示例6: testCreateGetAndDeleteGroup

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void testCreateGetAndDeleteGroup() throws Exception {
    clockService.setMockTime(LocalTime.of(10, 0)); // We're not allowed to create signups at night, so mocking time
    final LocalDateTime now = clockService.getCurrentDateTime();
    final LocalTime nowTime = now.toLocalTime();
    LocalDateTime endOfRaid = now.plusMinutes(45);
    final Gym gym = gymRepository.findByName("Blenda", uppsalaRegion);
    Raid enteiRaid = new Raid(pokemonRepository.search("Entei", null), endOfRaid, gym, localeService, uppsalaRegion);
    String raidCreatorName = "testUser1";
    User user = mock(User.class);
    when(user.getName()).thenReturn(raidCreatorName);
    Guild guild = mock(Guild.class);
    Config config = mock(Config.class);
    Raid enteiRaid1 = enteiRaid;
    try {
        enteiRaid1 = repo.newRaid(user, enteiRaid1, guild, config, "test");
    } catch (RuntimeException e) {
        System.err.println(e.getMessage());
        fail("Could not save raid: " + e.getMessage());
    }
    enteiRaid = enteiRaid1;
    User user2 = mock(User.class);
    String userName = "testUser2";
    when(user2.getName()).thenReturn(userName);
    LocalTime arrivalTime = nowTime.plusMinutes(30);
    RaidGroup group = new RaidGroup("testserver", "channel", "infoId", "emoteId", "userId",
            LocalDateTime.of(LocalDate.now(), arrivalTime));
    group = repo.newGroupForRaid(user2, group, enteiRaid, guild, config);
    List<RaidGroup> groupsForServer = repo.getGroupsForServer("testserver");
    assertThat(group != null, is(true));
    assertThat(groupsForServer.size(), is(1));
    assertThat(groupsForServer.iterator().next(), is(group));

    RaidGroup deleted = repo.deleteGroup(enteiRaid.getId(), group.getId());
    assertThat(deleted != null, is(true));
    groupsForServer = repo.getGroupsForServer("testserver");
    assertThat(groupsForServer.size(), is(0));
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:39,代碼來源:RaidRepositoryTest.java

示例7: testSignUp

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void testSignUp() throws Exception {
    clockService.setMockTime(LocalTime.of(10, 0)); // We're not allowed to create signups at night, so mocking time
    final LocalDateTime now = clockService.getCurrentDateTime();
    final LocalTime nowTime = now.toLocalTime();
    LocalDateTime endOfRaid = now.plusMinutes(45);
    final Gym gym = gymRepository.findByName("Blenda", uppsalaRegion);
    Raid enteiRaid = new Raid(pokemonRepository.search("Entei", null), endOfRaid, gym, localeService, uppsalaRegion);
    String raidCreatorName = "testUser1";
    User user = mock(User.class);
    when(user.getName()).thenReturn(raidCreatorName);
    Guild guild = mock(Guild.class);
    Config config = mock(Config.class);

    try {
        repo.newRaid(user, enteiRaid, guild, config, "test");
    } catch (RuntimeException e) {
        System.err.println(e.getMessage());
        fail("Could not save raid: " + e.getMessage());
    }
    User user2 = mock(User.class);
    String userName = "testUser2";
    when(user2.getName()).thenReturn(userName);
    Raid raid = repo.getActiveRaidOrFallbackToExRaid(gym, uppsalaRegion, user2);
    enteiRaid.setId(raid.getId()); // Set to same id for equals comparison
    enteiRaid.setCreator(raid.getCreator()); // Set creator to same for equals comparison
    assertThat(raid, is(enteiRaid));
    int howManyPeople = 3;
    LocalTime arrivalTime = nowTime.plusMinutes(30);
    raid.signUp(user2, howManyPeople, arrivalTime, repo);
    assertThat(raid.getSignUps().size(), is(1));
    assertThat(raid.getNumberOfPeopleSignedUp(), is(howManyPeople));

    final Raid raidFromDb = repo.getActiveRaidOrFallbackToExRaid(gym, uppsalaRegion, user2);
    assertThat(raidFromDb, is(raid));
    assertThat(raidFromDb.getSignUps().size(), is(1));
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:38,代碼來源:RaidRepositoryTest.java


注:本文中的java.time.LocalTime.plusMinutes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。