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


Java LocalTime.minusSeconds方法代码示例

本文整理汇总了Java中java.time.LocalTime.minusSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.minusSeconds方法的具体用法?Java LocalTime.minusSeconds怎么用?Java LocalTime.minusSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.minusSeconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: now_Clock_allSecsInDay_beforeEpoch

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
    LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L);
    for (int i =-1; i >= -(24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        ZonedDateTime test = ZonedDateTime.now(clock);
        assertEquals(test.getYear(), 1969);
        assertEquals(test.getMonth(), Month.DECEMBER);
        assertEquals(test.getDayOfMonth(), 31);
        expected = expected.minusSeconds(1);
        assertEquals(test.toLocalTime(), expected);
        assertEquals(test.getOffset(), ZoneOffset.UTC);
        assertEquals(test.getZone(), ZoneOffset.UTC);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TCKZonedDateTime.java

示例2: now_Clock_allSecsInDay_beforeEpoch

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
    LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L);
    for (int i =-1; i >= -(24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        OffsetDateTime test = OffsetDateTime.now(clock);
        assertEquals(test.getYear(), 1969);
        assertEquals(test.getMonth(), Month.DECEMBER);
        assertEquals(test.getDayOfMonth(), 31);
        expected = expected.minusSeconds(1);
        assertEquals(test.toLocalTime(), expected);
        assertEquals(test.getOffset(), ZoneOffset.UTC);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:TCKOffsetDateTime.java

示例3: now_Clock_allSecsInDay_beforeEpoch

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
    LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L);
    for (int i =-1; i >= -(24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalDateTime test = LocalDateTime.now(clock);
        assertEquals(test.getYear(), 1969);
        assertEquals(test.getMonth(), Month.DECEMBER);
        assertEquals(test.getDayOfMonth(), 31);
        expected = expected.minusSeconds(1);
        assertEquals(test.toLocalTime(), expected);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:TCKLocalDateTime.java

示例4: test_minusSeconds_one

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_minusSeconds_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    int hour = 0;
    int min = 0;
    int sec = 0;
    for (int i = 0; i < 3700; i++) {
        t = t.minusSeconds(1);
        sec--;
        if (sec == -1) {
            min--;
            sec = 59;

            if (min == -1) {
                hour--;
                min = 59;

                if (hour == -1) {
                    hour = 23;
                }
            }
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
        assertEquals(t.getSecond(), sec);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:TCKLocalTime.java

示例5: test_minusSeconds_fromZero

import java.time.LocalTime; //导入方法依赖的package包/类
@Test(dataProvider="minusSeconds_fromZero")
public void test_minusSeconds_fromZero(int seconds, int hour, int min, int sec) {
    LocalTime base = LocalTime.MIDNIGHT;
    LocalTime t = base.minusSeconds(seconds);

    assertEquals(t.getHour(), hour);
    assertEquals(t.getMinute(), min);
    assertEquals(t.getSecond(), sec);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKLocalTime.java


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