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


Java Instant类代码示例

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


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

示例1: exportCsv

import java.time.Instant; //导入依赖的package包/类
/**
 * Export result to csv
 *
 * @param requestParams the query of the transfer timing search
 * @param pageable      the pagination information
 * @return downloadable csv
 */
@GetMapping(value = "/transfer-timings.csv", produces = CsvMediaType.TEXT_CSV_VALUE)
@Timed
public ResponseEntity<List<TransferTimingListingDTO>> exportCsv(@RequestParam Map<String, String> requestParams, @ApiParam Pageable pageable) {
    /* ==========================
     * In this example you might not understand as I did not put the other part of code but I have a AbstractHttpMessageConverter
     * that converts object or list of objects to a CSV
     * ==========================
     */
    final List<TransferTimingListingDTO> list;

    if (requestParams != null) {
        list = transferTimingPageService.searchWithoutPaging(requestParams, pageable);
    } else {
        list = transferTimingPageService.getAllWithoutPaging(pageable);
    }

    String filename = "visual-timings-" + Instant.now().getEpochSecond() + ".csv";

    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename);
    headers.add("X-Save-As", filename);

    return new ResponseEntity<>(list, headers, HttpStatus.OK);
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:32,代码来源:TransferTimingPageResource.java

示例2: testCloseWithoutPersistedFile

import java.time.Instant; //导入依赖的package包/类
@Test(expected = ChronicleHashClosedException.class)
public void testCloseWithoutPersistedFile() {
  MetricStore heapStore = new VarBitMetricStore();
  long uuid1 = 1;
  long ts = Instant.now().getEpochSecond();
  double value = 100;

  heapStore.addPoint(uuid1, ts, value);
  OffHeapVarBitMetricStore offheapStore1 =
      OffHeapVarBitMetricStore.toOffHeapStore(getSeriesMap(heapStore), testFileName, "");

  assertEquals(1, offheapStore1.getSeriesMap().size());
  List<Point> points = offheapStore1.getSeries(uuid1);
  assertEquals(1, points.size());
  assertEquals(ts, points.get(0).getTs());
  assertEquals(value, points.get(0).getVal(), delta);

  offheapStore1.close();
  offheapStore1.getSeriesMap().size();
}
 
开发者ID:pinterest,项目名称:yuvi,代码行数:21,代码来源:OffHeapVarBitMetricStoreTest.java

示例3: build

import java.time.Instant; //导入依赖的package包/类
private synchronized _BridgeSubscription build(String subId, String sourceMxId, Instant timestamp, String email, String threadId, String mxId, String roomId) {
    log.info("Creating new subscription {} for email {} with threadId {} and matrix id {} in room {}",
            subId,
            email,
            threadId,
            mxId,
            roomId);

    _EmailEndPoint emEp = emMgr.getEndpoint(email, threadId);
    _MatrixEndPoint mxEp = mxMgr.getEndpoint(mxId, roomId);
    String eKey = emMgr.getKey(email, threadId);
    String mKey = mxMgr.getKey(mxId, roomId);

    _BridgeSubscription sub = new BridgeSubscription(subId, sourceMxId, timestamp, formatter, eKey, emEp, mKey, mxEp);
    sub.addListener(this::remove);

    subs.put(subId, sub);
    subsEmailKey.put(eKey, new WeakReference<>(sub));
    subsMatrixKey.put(mKey, new WeakReference<>(sub));

    return sub;
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:23,代码来源:SubscriptionManager.java

示例4: testImageCapture2

import java.time.Instant; //导入依赖的package包/类
@Test
public void testImageCapture2() throws IOException {
    AVFImageCaptureService service = AVFImageCaptureService.getInstance();
    AVFImageCapture ic = service.getImageCapture();
    String[] devices = ic.videoDevicesAsStrings();
    if (devices.length > 0) {
        ic.startSessionWithNamedDevice(devices[0]);
        Path path = Paths.get("target",
                getClass().getSimpleName() + "-1-" + Instant.now() + ".png");
        Optional<Image> png = ic.capture(path.toFile());
        ic.stopSession();
        Assert.assertTrue(png.isPresent());

    }
    else {
        System.err.println("No frame capture devices were found");
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:19,代码来源:AVFImageCaptureServiceTest.java

示例5: changeCloseConditionsOfOrder

import java.time.Instant; //导入依赖的package包/类
@Override
public Optional<Failed> changeCloseConditionsOfOrder(final CloseConditions conditions) {
    final Optional<Failed> failed = orderManagement.changeCloseConditionsOfOrder(conditions);

    final Instant time = currentTime.get();
    events.add(new TradeEvent(CLOSE_CONDITIONS_CHANGED, time, "expert advisor changed close conditions",
            conditions));
    if (failed.isPresent()) {
        events.add(new TradeEvent(CLOSE_CONDITIONS_CHANGED, time,
                "broker faild to changed close conditions of expert advisor: " + failed.get(),
                currentCloseConditions));
    } else {
        currentCloseConditions = conditions;
    }

    return failed;
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:18,代码来源:TradeTracker.java

示例6: addDateRangeRule

import java.time.Instant; //导入依赖的package包/类
/**
 * Helper method to add a DateRange Commission Rule to the Commission ruleset.
 * Should only be called from getCommissionRuleSetWithDateRanges.
 */
private static Builder<RuleSetBuilder, DecisionTreeRuleSet> addDateRangeRule(
        final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder,
        final String startDate, final String endDate,
        final String exmethod, final String exchange,
        final String product, final String region,
        final String asset, final Instant start,
        final Instant finish, final long ruleId, final String rate) {
    return ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("DR:" + startDate + "|" + endDate,
                    exmethod, exchange, product, region, asset))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0L, ruleId))
            .with(RuleBuilder::setCode, new UUID(0L, ruleId))
            .with(RuleBuilder::output, Collections.singletonMap("Rate", rate)));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:21,代码来源:CommisionRuleSetSupplier.java

示例7: connect

import java.time.Instant; //导入依赖的package包/类
private final int connect(int times) {
    times++;
    if(times > reconnection_tries) {
        instant_started = null;
        return times;
    }
    try {
        StaticStandard.log(String.format("[CLIENT] Started connecting to %s (Try: %d)", formatAddressAndPort(), times));
        socket = new Socket(inetaddress, port);
        setSocket(socket);
        instant_started = Instant.now();
        connected = true;
        if(!isServerClient) {
            send(MessageState.LOGIN);
        }
        disconnected = false;
        StaticStandard.log("[CLIENT] Connected successfully to " + formatAddressAndPort());
    } catch (Exception ex) {
        StaticStandard.logErr("[CLIENT] Error while connecting to server: " + ex);
        instant_started = null;
    }
    isConnected(times);
    return times;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:25,代码来源:Client.java

示例8: storeMessage

import java.time.Instant; //导入依赖的package包/类
/**
 * Stores a new secure message and return the senderId.
 */
public String storeMessage(final String message, final List<SecretFile> files,
                           final KeyIv encryptionKey,
                           final byte[] linkSecret,
                           final String password,
                           final Instant expiration) {

    final boolean isMessagePasswordProtected = password != null;

    final String senderId = newRandomId();

    final String receiverId = storeMessage(
        senderId, message, encryptionKey, files,
        linkSecret, password, expiration);

    saveSenderMessage(senderId,
        new SenderMessage(senderId, receiverId, isMessagePasswordProtected, expiration));

    return senderId;
}
 
开发者ID:osiegmar,项目名称:setra,代码行数:23,代码来源:MessageSenderService.java

示例9: chronoRangeCompareTest10

import java.time.Instant; //导入依赖的package包/类
@Test
public void chronoRangeCompareTest10() {
    ChronoSeries chronoSeries = ChronoSeries.of(
            Instant.parse("2017-02-28T08:48:11Z"),
            Instant.parse("2017-02-28T08:48:12Z"),
            Instant.parse("2017-02-28T08:48:13Z"),
            Instant.parse("2017-02-28T08:48:14Z"),
            Instant.parse("2017-02-28T08:48:15Z")
    );
    ISeq<ChronoGene> genes = ISeq.of(
            new ChronoGene(new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.SECONDS), 0, 10)),
            new ChronoGene(new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.SECONDS), 0, 11))
    );
    ChronoRange chronoRange = ChronoRange.getChronoRange(chronoSeries, genes);

    genes = ISeq.of(
            new ChronoGene(new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.SECONDS), 0, 11)),
            new ChronoGene(new ChronoPattern(ChronoScaleUnit.asFactual(chronoSeries, ChronoUnit.SECONDS), 0, 10))
    );
    ChronoRange chronoRange2 = ChronoRange.getChronoRange(chronoSeries, genes);

    assertTrue(chronoRange.isSameChronoRange(chronoRange2));
}
 
开发者ID:BFergerson,项目名称:Chronetic,代码行数:24,代码来源:ChronoRangeTest.java

示例10: testResourcePast

import java.time.Instant; //导入依赖的package包/类
@Test
public void testResourcePast() {
    final Instant time = parse("2017-02-15T11:00:00Z");
    final Resource res = VersionedResource.find(file, identifier, time).get();
    assertEquals(identifier, res.getIdentifier());
    assertFalse(res.hasAcl());
    assertEquals(LDP.Container, res.getInteractionModel());
    assertFalse(res.getMembershipResource().isPresent());
    assertFalse(res.getMemberRelation().isPresent());
    assertFalse(res.getMemberOfRelation().isPresent());
    assertFalse(res.getInsertedContentRelation().isPresent());
    assertFalse(res.getBinary().isPresent());
    assertTrue(res.isMemento());
    assertFalse(res.getInbox().isPresent());
    assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
    assertEquals(0L, res.getTypes().size());
    assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());

    final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
    assertEquals(0L, triples.size());

    final List<VersionRange> mementos = res.getMementos();
    assertEquals(1L, mementos.size());
    assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
    assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:27,代码来源:LdpContainerTest.java

示例11: buildGoLiveEmbed

import java.time.Instant; //导入依赖的package包/类
public static MessageEmbed buildGoLiveEmbed(BTBBeamChannel channel) {
	return new EmbedBuilder()
			.setTitle(String.format("%s is now live!", channel.user.username),
					String.format("https://beam.pro/%s", channel.user.username))
			.setThumbnail(String.format("https://beam.pro/api/v1/users/%d/avatar?_=%d", channel.user.id,
					new Random().nextInt()))
			.setDescription(StringUtils.isBlank(channel.user.bio) ? "No bio" : channel.user.bio)
			.addField(channel.name, channel.type == null ? "No game selected" : channel.type.name, false)
			.addField("Followers", Integer.toString(channel.numFollowers), true)
			.addField("Views", Integer.toString(channel.viewersTotal), true)
			.addField("Rating", Enums.serializedName(channel.audience), true)
			.setImage(String.format("https://thumbs.beam.pro/channel/%d.small.jpg?_=%d", channel.id,
					new Random().nextInt()))
			.setFooter("Beam.pro", CommandHelper.BEAM_LOGO_URL).setTimestamp(Instant.now())
			.setColor(CommandHelper.COLOR).build();
}
 
开发者ID:StreamerSpectrum,项目名称:BeamTeamDiscordBot,代码行数:17,代码来源:JDAManager.java

示例12: getLocalImageTimestamp

import java.time.Instant; //导入依赖的package包/类
private static Instant getLocalImageTimestamp(String imageName) {
	// Use docker inspect
	try {
		String isoDatetime = DefaultCommandRunner.INSTANCE.runCommandAndCaptureOutput("docker", "inspect", "-f", "{{.Created}}", imageName);
		return Instant.from(DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(isoDatetime));
	}
	catch (RuntimeException e) {
		log.debug("Could not determine timestamp of local image [" + imageName + "], assuming it doesn't exist on the local docker host", e);
		return null;
	}
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:12,代码来源:DockerRegistry.java

示例13: toTableRow

import java.time.Instant; //导入依赖的package包/类
public TableRow toTableRow() {
  TableRow result = new TableRow();
  result.set("latitude", lat);
  result.set("longitude", lon);
  result.set("ride_id", rideId);
  result.set("timestamp", Instant.ofEpochMilli(timestamp).toString());
  result.set("ride_status", status);
  return result;
}
 
开发者ID:googlecodelabs,项目名称:cloud-dataflow-nyc-taxi-tycoon,代码行数:10,代码来源:RidePoint.java

示例14: enqueue

import java.time.Instant; //导入依赖的package包/类
private synchronized void enqueue(Map<String, String> entry) {
    if (queue.size() > QUEUE_MAX_SIZE) {
        queue.poll();
    }
    if (entry != null) {
        entry.put(TIMESTAMP_NAME, Instant.now().toString());
        queue.add(entry);
    }
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:10,代码来源:UsageDataStore.java

示例15: onGuildVoiceMute

import java.time.Instant; //导入依赖的package包/类
@Override
public final void onGuildVoiceMute(GuildVoiceMuteEvent event) {
    if (!LOG_MUTES) {
        return;
    }
    Standard.log(Instant.now(), event.getGuild(), LOG_NAME, LOG_CHANNEL_ID_VOICE, LOG_TEXT_VOICE_MUTE, "[%1$s] [%2$s] %3$s was %4$s", LOG_DATE_TIME_FORMAT, Config.CONFIG.getUserNameForUser(event.getMember().getUser(), event.getGuild(), true), (event.isMuted() ? "muted" : "unmuted"));
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:8,代码来源:GuildVoiceLogger.java


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