本文整理汇总了Java中java.time.LocalDateTime.plusMinutes方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.plusMinutes方法的具体用法?Java LocalDateTime.plusMinutes怎么用?Java LocalDateTime.plusMinutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.plusMinutes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetters
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void testSetters() throws Exception {
String timeValue = "2000-12-01 12:55";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
LocalDateTime timeStart = LocalDateTime.parse(timeValue, formatter);
LocalDateTime timeStop = timeStart.plusMinutes(90);
PSP.Phase phase = PSP.Phase.PostMortem;
int interruption = 30;
String comments = "this is a test";
testLog.setTimeStart(timeStart);
testLog.setTimeStop(timeStop);
testLog.setInterruptionMin(interruption);
testLog.setPhase(phase);
testLog.setComments(comments);
Assert.assertEquals(timeStart, testLog.getTimeStart());
Assert.assertEquals(timeStop, testLog.getTimeStop());
Assert.assertEquals(interruption, testLog.getInterruptionMin());
Assert.assertEquals(phase, testLog.getPhase());
Assert.assertEquals(comments, testLog.getComments());
}
示例2: getTimestamp
import java.time.LocalDateTime; //导入方法依赖的package包/类
public Timestamp getTimestamp(String daysS, String hoursS, String minutesS){
daysS = daysS==null || daysS.equals("") ? "0" : daysS;
hoursS = hoursS==null || hoursS.equals("") ? "0" : hoursS;
minutesS = minutesS==null || minutesS.equals("") ? "0" : minutesS;
Integer days = Integer.parseInt(daysS);
Integer hours = Integer.parseInt(hoursS);
Integer minutes = Integer.parseInt(minutesS);
if(days==0 && hours==0 && minutes==0){
days = 10000;
hours = 11;
minutes = 59;
}
days = days > 10000 ? 10000 : days;
hours = hours%24;
minutes = minutes%60;
LocalDateTime localDateTime = LocalDateTime.now();
localDateTime = localDateTime.plusDays(days);
localDateTime = localDateTime.plusHours(hours);
localDateTime = localDateTime.plusMinutes(minutes);
return Timestamp.valueOf(localDateTime);
}
示例3: test_plusMinutes_one
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void test_plusMinutes_one() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
LocalDate d = t.toLocalDate();
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.toLocalDate(), d);
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
}
}
示例4: test_plusMinutes_fromZero
import java.time.LocalDateTime; //导入方法依赖的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));
}
}
示例5: raidsCollide
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void raidsCollide() throws Exception {
final ClockService currentTimeService = new ClockService();
currentTimeService.setMockTime(LocalTime.of(10, 0));
LocalDateTime startOne = currentTimeService.getCurrentDateTime();
LocalDateTime endOne = startOne.plusHours(1);
LocalDateTime startTwo = currentTimeService.getCurrentDateTime().minusMinutes(1);
LocalDateTime endTwo = startTwo.plusHours(1);
assertThat(Utils.raidsCollide(endOne, false, endTwo, false), is(true));
assertThat(Utils.raidsCollide(endTwo, false, endOne, false), is(true));
startOne = currentTimeService.getCurrentDateTime();
endOne = startOne.plusMinutes(10);
startTwo = currentTimeService.getCurrentDateTime().plusMinutes(11);
endTwo = startTwo.plusHours(1);
assertThat(Utils.raidsCollide(endOne, false, endTwo, false), is(false));
assertThat(Utils.raidsCollide(endTwo, false, endOne, false), is(false));
}
示例6: timeInRaidspan
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void timeInRaidspan() throws Exception {
User user = mock(User.class);
when(user.getName()).thenReturn("User");
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime same = localDateTime;
LocalDateTime before = localDateTime.minusMinutes(1);
LocalDateTime after = localDateTime.plusMinutes(1);
LocalDateTime end = localDateTime.plusMinutes(Utils.RAID_DURATION_IN_MINUTES);
LocalDateTime sameAsEnd = end;
LocalDateTime beforeEnd = end.minusMinutes(1);
LocalDateTime afterEnd = end.plusMinutes(1);
final LocaleService localeService = mock(LocaleService.class);
when(localeService.getMessageFor(any(), any(), any())).thenReturn("Mupp");
Raid raid = new Raid(pokemonRepository.getByName("Tyranitar"), end,
new Gym("Test", "id", "10", "10", null),
localeService, "Test");
checkWhetherAssertFails(user, same, localeService, raid, false);
checkWhetherAssertFails(user, after, localeService, raid, false);
checkWhetherAssertFails(user, before, localeService, raid, true);
checkWhetherAssertFails(user, sameAsEnd, localeService, raid, false);
checkWhetherAssertFails(user, afterEnd, localeService, raid, true);
checkWhetherAssertFails(user, beforeEnd, localeService, raid, false);
}
示例7: getVehiclesByDatePage_NullParams
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* When you pass in null date and page, it should default to today and page 1,
* so we're expecting to see a request from midnight today to midnight today +
* 1 minute
*/
@Test
public void getVehiclesByDatePage_NullParams() {
LocalDateTime start = atMidnight(LocalDateTime.now());
LocalDateTime end = start.plusMinutes(1); // pages are one minute in size
Date startDate = localDateTimeToDate(start);
Date endDate = localDateTimeToDate(end);
tradeReadService.getVehiclesByDatePage(null, null);
verify(tradeReadDaoMock).getVehiclesMotTestsByDateRange(startDate, endDate);
}
示例8: getLabelBatchHisto
import java.time.LocalDateTime; //导入方法依赖的package包/类
/** Renvoie le label d'historique
* @param batchHisto
* @return
*/
private String getLabelBatchHisto(BatchHisto batchHisto){
String txt = batchHisto.getStateBatchHisto()
+" - "+applicationContext.getMessage("batch.histo.deb", new Object[]{batchHisto.getDateDebBatchHisto().format(formatterDateTime)}, UI.getCurrent().getLocale());
if (batchHisto.getDateFinBatchHisto()!=null){
LocalDateTime dateDeb = LocalDateTime.from(batchHisto.getDateDebBatchHisto());
Long minutes = dateDeb.until(batchHisto.getDateFinBatchHisto(), ChronoUnit.MINUTES);
dateDeb = dateDeb.plusMinutes(minutes);
Long secondes = dateDeb.until(batchHisto.getDateFinBatchHisto(), ChronoUnit.SECONDS);
txt += " - "+applicationContext.getMessage("batch.histo.fin", new Object[]{batchHisto.getDateFinBatchHisto().format(formatterDateTime)}, UI.getCurrent().getLocale());
txt += " - "+applicationContext.getMessage("batch.histo.duree", new Object[]{getTimeFormated(minutes),getTimeFormated(secondes)}, UI.getCurrent().getLocale());
}
return txt;
}
示例9: getVehiclesByDatePage_NullPage
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Ask for a date two weeks ago, but with a null page so it should default to
* asking for that date and a date one minute later
*/
@Test
public void getVehiclesByDatePage_NullPage() {
LocalDateTime start = LocalDateTime.now().minusWeeks(2); // request for
// two weeks ago
LocalDateTime expectedStart = atMidnight(start);
LocalDateTime expectedEnd = expectedStart.plusMinutes(1);
tradeReadService.getVehiclesByDatePage(localDateTimeToDate(start), null);
verify(tradeReadDaoMock).getVehiclesMotTestsByDateRange(localDateTimeToDate(expectedStart),
localDateTimeToDate(expectedEnd));
}
示例10: getVehiclesByDatePage_DateAndPage
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Ask for a date two weeks ago and page 10, which should ask for that date +
* 10 minutes to that date + 11 minutes.
*/
@Test
public void getVehiclesByDatePage_DateAndPage() {
LocalDateTime start = LocalDateTime.now().minusWeeks(2); // request for
// two weeks ago
LocalDateTime expectedStart = atMidnight(start).plusMinutes(9);
LocalDateTime expectedEnd = expectedStart.plusMinutes(1);
tradeReadService.getVehiclesByDatePage(localDateTimeToDate(start), 10);
verify(tradeReadDaoMock).getVehiclesMotTestsByDateRange(localDateTimeToDate(expectedStart),
localDateTimeToDate(expectedEnd));
}
示例11: computeFirstResetTime
import java.time.LocalDateTime; //导入方法依赖的package包/类
protected static LocalDateTime computeFirstResetTime(LocalDateTime baseTime, int time, TimeUnit unit) {
if (unit != TimeUnit.SECONDS && unit != TimeUnit.MINUTES && unit != TimeUnit.HOURS && unit != TimeUnit.DAYS) {
throw new IllegalArgumentException();
}
LocalDateTime t = baseTime;
switch (unit) {
case DAYS:
t = t.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
break;
case HOURS:
if (24 % time == 0) {
t = t.plusHours(time - t.getHour() % time);
} else {
t = t.plusHours(1);
}
t = t.withMinute(0).withSecond(0).withNano(0);
break;
case MINUTES:
if (60 % time == 0) {
t = t.plusMinutes(time - t.getMinute() % time);
} else {
t = t.plusMinutes(1);
}
t = t.withSecond(0).withNano(0);
break;
case SECONDS:
if (60 % time == 0) {
t = t.plusSeconds(time - t.getSecond() % time);
} else {
t = t.plusSeconds(1);
}
t = t.withNano(0);
break;
}
return t;
}
示例12: testCreateGetAndDeleteGroup
import java.time.LocalDateTime; //导入方法依赖的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));
}
示例13: testSignUp
import java.time.LocalDateTime; //导入方法依赖的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));
}
示例14: changePokemonWorks
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void changePokemonWorks() 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);
Guild guild = mock(Guild.class);
Config config = mock(Config.class);
when(user.getName()).thenReturn(raidCreatorName);
try {
repo.newRaid(user, enteiRaid, guild, config, "test");
} catch (RuntimeException e) {
System.err.println(e.getMessage());
fail("Could not save raid: " + e.getMessage());
}
Raid raid = repo.getActiveRaidOrFallbackToExRaid(gym, uppsalaRegion, user);
Raid changedRaid = repo.changePokemon(raid, pokemonRepository.search("Mewtwo", user), guild,
config, user, "test");
assertThat(raid.getEndOfRaid(), is(changedRaid.getEndOfRaid()));
assertThat(raid.getGym(), is(changedRaid.getGym()));
assertThat(raid.getSignUps(), is(changedRaid.getSignUps()));
assertThat(raid.getRegion(), is(changedRaid.getRegion()));
assertThat(raid.getPokemon().getName(), is("Entei"));
assertThat(changedRaid.getPokemon().getName(), is("Mewtwo"));
}
示例15: getVehiclesByDatePageTestHelper
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Run a common format page capping test on getVehiclesByDatePage
*/
private void getVehiclesByDatePageTestHelper(int pageToRequest, int pageExpected) {
LocalDateTime start = LocalDateTime.now().minusWeeks(2);
LocalDateTime expectedStart = atMidnight(start).plusMinutes(pageExpected - 1);
LocalDateTime expectedEnd = expectedStart.plusMinutes(1);
tradeReadService.getVehiclesByDatePage(localDateTimeToDate(start), pageToRequest);
verify(tradeReadDaoMock).getVehiclesMotTestsByDateRange(localDateTimeToDate(expectedStart),
localDateTimeToDate(expectedEnd));
}