当前位置: 首页>>代码示例>>Java>>正文


Java LocalDateTime.minusMinutes方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:TCKLocalDateTime.java

示例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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TCKLocalDateTime.java

示例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);
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:25,代码来源:UtilsTest.java

示例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);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:44,代码来源:LocalDateTimeDemo.java

示例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);
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:5,代码来源:Utils.java


注:本文中的java.time.LocalDateTime.minusMinutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。