java.time.LocalTime#now ( )源码实例Demo

下面列出了java.time.LocalTime#now ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: blynk-server   文件: TimerTest.java
@Test
public void testAddTimerWidgetWithStopTimeAndRemove() throws Exception {
    ses.scheduleAtFixedRate(holder.timerWorker, 0, 1000, TimeUnit.MILLISECONDS);
    Timer timer = new Timer();
    timer.id = 112;
    timer.x = 1;
    timer.y = 1;
    timer.pinType = PinType.DIGITAL;
    timer.pin = 5;
    timer.width = 2;
    timer.height = 1;
    timer.startValue = "1";
    timer.stopValue = "0";
    LocalTime localDateTime = LocalTime.now(ZoneId.of("UTC"));
    int curTime = localDateTime.toSecondOfDay();
    timer.startTime = curTime + 1;
    timer.stopTime = curTime + 2;

    clientPair.appClient.createWidget(1, timer);
    clientPair.appClient.verifyResult(ok(1));

    clientPair.appClient.deleteWidget(1, 112);
    clientPair.appClient.verifyResult(ok(2));

    verify(clientPair.hardwareClient.responseMock, after(2500).never()).channelRead(any(), any());
}
 
源代码2 项目: java-trader   文件: MarketDayUtil.java
public static LocalDate thisOrNextMarketDay(Exchange exchange, LocalDate tradingDay, boolean thisCompleted){
    if ( exchange==null) {
        exchange = Exchange.SSE;
    }
    if( tradingDay==null ) {
        tradingDay = LocalDate.now(exchange.getZoneId());
    }
    LocalTime thisTime = LocalTime.now(exchange.getZoneId());
    if ( thisCompleted && thisTime.compareTo(exchange.getMarketTimes()[1])<=0 ){
        tradingDay = tradingDay.plusMonths(1);
    }
    if ( isMarketDay(exchange, tradingDay) ) {
        return tradingDay;
    }
    return nextMarketDay(exchange, tradingDay);
}
 
源代码3 项目: openjdk-jdk9   文件: TCKLocalTime.java
@Test
public void now_Clock_allSecsInDay() {
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalTime test = LocalTime.now(clock);
        assertEquals(test.getHour(), (i / (60 * 60)) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 60);
        assertEquals(test.getNano(), 8);
    }
}
 
源代码4 项目: openjdk-8   文件: TCKLocalTime.java
@Test
public void now_Clock_allSecsInDay() {
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalTime test = LocalTime.now(clock);
        assertEquals(test.getHour(), (i / (60 * 60)) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 60);
        assertEquals(test.getNano(), 8);
    }
}
 
@Test
public void testPreRegistration() {
    List<TicketCategoryModification> categories = Collections.singletonList(
            new TicketCategoryModification(null, "default", 10,
                    new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()),
                    new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()),
                    DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null, 0, null, null, AlfioMetadata.empty()));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
    Event event = pair.getKey();
    waitingQueueManager.subscribe(event, new CustomerName("Giuseppe Garibaldi", "Giuseppe", "Garibaldi", event.mustUseFirstAndLastName()), "[email protected]", null, Locale.ENGLISH);
    waitingQueueManager.subscribe(event, new CustomerName("Nino Bixio", "Nino", "Bixio", event.mustUseFirstAndLastName()), "[email protected]", null, Locale.ITALIAN);
    assertTrue(waitingQueueRepository.countWaitingPeople(event.getId()) == 2);

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
    assertEquals(18, ticketRepository.findFreeByEventId(event.getId()).size());

    TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10,
            new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
            DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null, 0, null, null, AlfioMetadata.empty());
    eventManager.insertCategory(event.getId(), tcm, pair.getValue());

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);

    List<WaitingQueueSubscription> subscriptions = waitingQueueRepository.loadAll(event.getId());
    assertEquals(2, subscriptions.stream().filter(w -> StringUtils.isNotBlank(w.getReservationId())).count());
    assertTrue(subscriptions.stream().allMatch(w -> w.getStatus().equals(WaitingQueueSubscription.Status.PENDING)));
    assertTrue(subscriptions.stream().allMatch(w -> w.getSubscriptionType().equals(WaitingQueueSubscription.Type.PRE_SALES)));

}
 
@Test
public void testTimeColumn() {
  LocalTime now = LocalTime.now(ZoneId.systemDefault());

  Long value = now.toNanoOfDay();
  primeWithType(value, TIME);
  ResultSet resultSet = getResultSet();

  Schema schema = Schema.builder().addNullableField("col", FieldType.INT64).build();
  Row expected = Row.withSchema(schema).addValue(value).build();

  assertEquals(expected, cassandraRowMapper.map(resultSet).next());
}
 
源代码7 项目: dragonwell8_jdk   文件: TCKLocalTime.java
@Test
public void now_Clock_min() {
    Clock clock = Clock.fixed(Instant.MIN, ZoneOffset.UTC);
    LocalTime test = LocalTime.now(clock);
    assertEquals(test.getHour(), 0);
    assertEquals(test.getMinute(), 0);
    assertEquals(test.getSecond(), 0);
    assertEquals(test.getNano(), 0);
}
 
源代码8 项目: dragonwell8_jdk   文件: TCKLocalTime.java
@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    LocalTime expected = LocalTime.now(Clock.system(zone));
    LocalTime test = LocalTime.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = LocalTime.now(Clock.system(zone));
        test = LocalTime.now(zone);
    }
    assertEquals(test, expected);
}
 
源代码9 项目: j2objc   文件: TCKLocalTime.java
@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    LocalTime expected = LocalTime.now(Clock.system(zone));
    LocalTime test = LocalTime.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = LocalTime.now(Clock.system(zone));
        test = LocalTime.now(zone);
    }
    assertEquals(test, expected);
}
 
源代码10 项目: antsdb   文件: CurrentTime.java
@Override
public long eval(VdmContext ctx, Heap heap, Parameters params, long pRecord) {
	LocalTime time = LocalTime.now();
	Duration duration = Duration.ofSeconds(time.getHour() * 3600 + time.getMinute() * 60 + time.getSecond());
    long addr = FishTime.allocSet(heap, duration);
    return addr;
}
 
源代码11 项目: jdk8u-jdk   文件: TCKLocalTime.java
@Test
public void now_Clock_allSecsInDay() {
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalTime test = LocalTime.now(clock);
        assertEquals(test.getHour(), (i / (60 * 60)) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 60);
        assertEquals(test.getNano(), 8);
    }
}
 
源代码12 项目: blynk-server   文件: TimerTest.java
@Test
public void testTimerWidgetTriggeredAndSendCommandToCorrectDevice() throws Exception {
    TestHardClient hardClient2 = new TestHardClient("localhost", properties.getHttpPort());
    hardClient2.start();

    ses.scheduleAtFixedRate(holder.timerWorker, 0, 1000, TimeUnit.MILLISECONDS);

    clientPair.appClient.deactivate(1);
    clientPair.appClient.verifyResult(ok(1));

    Timer timer = new Timer();
    timer.id = 1;
    timer.x = 1;
    timer.y = 1;
    timer.pinType = PinType.DIGITAL;
    timer.pin = 5;
    timer.startValue = "1";
    timer.stopValue = "0";
    LocalTime localDateTime = LocalTime.now(ZoneId.of("UTC"));
    int curTime = localDateTime.toSecondOfDay();
    timer.startTime = curTime + 1;
    timer.stopTime = curTime + 2;

    DashBoard dashBoard = new DashBoard();
    dashBoard.id = 1;
    dashBoard.name = "Test";
    dashBoard.widgets = new Widget[] {timer};

    clientPair.appClient.updateDash(dashBoard);
    clientPair.appClient.verifyResult(ok(2));

    dashBoard.id = 2;
    clientPair.appClient.createDash(dashBoard);
    clientPair.appClient.verifyResult(ok(3));

    clientPair.appClient.activate(1);
    clientPair.appClient.verifyResult(ok(4));

    clientPair.appClient.reset();
    clientPair.appClient.createDevice(2, new Device(1, "Device", BoardType.ESP8266));
    Device device = clientPair.appClient.parseDevice();
    hardClient2.login(device.token);
    hardClient2.verifyResult(ok(1));
    hardClient2.reset();

    verify(clientPair.hardwareClient.responseMock, timeout(2000)).channelRead(any(), eq(hardware(7777, "dw 5 1")));
    clientPair.hardwareClient.reset();
    verify(clientPair.hardwareClient.responseMock, timeout(2000)).channelRead(any(), eq(hardware(7777, "dw 5 0")));

    verify(hardClient2.responseMock, never()).channelRead(any(), any());
    hardClient2.stop().awaitUninterruptibly();
}
 
源代码13 项目: plugins   文件: ReportButtonPlugin.java
private String getJagexTime()
{
	LocalTime time = LocalTime.now(JAGEX);
	return time.format(timeFormat);
}
 
源代码14 项目: jdk8u_jdk   文件: TCKLocalTime.java
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullClock() {
    LocalTime.now((Clock) null);
}
 
源代码15 项目: dragonwell8_jdk   文件: TCKLocalTime.java
@Test(expectedExceptions=NullPointerException.class)
public void now_ZoneId_nullZoneId() {
    LocalTime.now((ZoneId) null);
}
 
源代码16 项目: Spring-Boot-2-Fundamentals   文件: BlogService.java
public String getTimeMessage(){
    return "It is "+LocalTime.now();
}
 
源代码17 项目: TencentKona-8   文件: TCKLocalTime.java
@Test(expectedExceptions=NullPointerException.class)
public void now_ZoneId_nullZoneId() {
    LocalTime.now((ZoneId) null);
}
 
源代码18 项目: runelite   文件: ReportButtonPlugin.java
private String getJagexTime()
{
	LocalTime time = LocalTime.now(JAGEX);
	return time.format(timeFormat);
}
 
源代码19 项目: blynk-server   文件: TimerTest.java
@Test
public void testTimerWidgetTriggeredAndSyncWorks() throws Exception {
    ses.scheduleAtFixedRate(holder.timerWorker, 0, 1000, TimeUnit.MILLISECONDS);

    clientPair.appClient.deactivate(1);
    clientPair.appClient.verifyResult(ok(1));

    Timer timer = new Timer();
    timer.id = 1;
    timer.x = 1;
    timer.y = 1;
    timer.pinType = PinType.VIRTUAL;
    timer.pin = 5;
    timer.startValue = "1";
    timer.stopValue = "0";
    LocalTime localDateTime = LocalTime.now(ZoneId.of("UTC"));
    int curTime = localDateTime.toSecondOfDay();
    timer.startTime = curTime + 1;
    timer.stopTime = curTime + 2;

    DashBoard dashBoard = new DashBoard();
    dashBoard.id = 1;
    dashBoard.name = "Test";
    dashBoard.widgets = new Widget[] {timer};

    clientPair.appClient.updateDash(dashBoard);
    clientPair.appClient.verifyResult(ok(2));

    clientPair.appClient.activate(1);
    clientPair.appClient.verifyResult(ok(3));

    verify(clientPair.hardwareClient.responseMock, timeout(2000)).channelRead(any(), eq(hardware(7777, "vw 5 1")));
    clientPair.hardwareClient.reset();
    clientPair.hardwareClient.sync(PinType.VIRTUAL, 5);
    verify(clientPair.hardwareClient.responseMock, timeout(2000)).channelRead(any(), eq(hardware(1, "vw 5 1")));

    verify(clientPair.hardwareClient.responseMock, timeout(2000)).channelRead(any(), eq(hardware(7777, "vw 5 0")));

    clientPair.hardwareClient.sync(PinType.VIRTUAL, 5);
    verify(clientPair.hardwareClient.responseMock, timeout(2000)).channelRead(any(), eq(hardware(2, "vw 5 0")));
}
 
源代码20 项目: dragonwell8_jdk   文件: TCKLocalTime.java
@Test(expectedExceptions=NullPointerException.class)
public void now_Clock_nullClock() {
    LocalTime.now((Clock) null);
}