当前位置: 首页>>代码示例>>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;未经允许,请勿转载。