本文整理汇总了Java中java.time.LocalDateTime.minusMinutes方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.minusMinutes方法的具体用法?Java LocalDateTime.minusMinutes怎么用?Java LocalDateTime.minusMinutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.minusMinutes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_minusMinutes_one
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void test_minusMinutes_one() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
LocalDate d = t.toLocalDate().minusDays(1);
int hour = 0;
int min = 0;
for (int i = 0; i < 70; i++) {
t = t.minusMinutes(1);
min--;
if (min == -1) {
hour--;
min = 59;
if (hour == -1) {
hour = 23;
}
}
assertEquals(t.toLocalDate(), d);
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
}
}
示例2: test_minusMinutes_fromZero
import java.time.LocalDateTime; //导入方法依赖的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);
}
}
示例3: 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);
}
示例4: testClac
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* 时间计算,减法操作
*/
@Test
public void testClac(){
LocalDateTime ldt = LocalDateTime.now();
System.out.println(ldt);
// 减: 天
LocalDateTime days = ldt.minusDays(1);
System.out.println("day: " + days);
// 减: 小时
LocalDateTime hours = ldt.minusHours(1);
System.out.println("hours: " + hours);
// 减: 分钟
LocalDateTime minutes = ldt.minusMinutes(1);
System.out.println("minutes: " + minutes);
// 减: 月
LocalDateTime months = ldt.minusMonths(1);
System.out.println("months: " + months);
// 减: 纳秒
LocalDateTime nanos = ldt.minusNanos(1);
System.out.println("nanos: " + nanos);
// 减: 秒
LocalDateTime seconds = ldt.minusSeconds(1);
System.out.println("seconds: " + seconds);
// 减: 周
LocalDateTime weeks = ldt.minusWeeks(1);
System.out.println("weeks: " + weeks);
// 减: 年
LocalDateTime years = ldt.minusYears(1);
System.out.println("years: " + years);
System.out.println(ldt);
}
示例5: getStartOfRaid
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static LocalDateTime getStartOfRaid(LocalDateTime endOfRaid, boolean isExRaid) {
return isExRaid ? endOfRaid.minusMinutes(RAID_DURATION_IN_MINUTES) :
endOfRaid.minusMinutes(RAID_DURATION_IN_MINUTES);
}