org.bitcoinj.core.Utils.dateTimeFormat()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.bitcoinj.core.Utils.dateTimeFormat()方法的一些代码示例,展示了Utils.dateTimeFormat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.dateTimeFormat()方法的具体详情如下:
包路径:org.bitcoinj.core.Utils
类名称:Utils
方法名:dateTimeFormat

Utils.dateTimeFormat介绍

[英]Formats a given date+time value to an ISO 8601 string.
[中]将给定的日期+时间值格式化为ISO 8601字符串。

代码示例

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Called when download progress is made.
 *
 * @param pct  the percentage of chain downloaded, estimated
 * @param date the date of the last block downloaded
 */
protected void progress(double pct, int blocksSoFar, Date date) {
  log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar,
      Utils.dateTimeFormat(date)));
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Called when download progress is made.
 *
 * @param pct  the percentage of chain downloaded, estimated
 * @param date the date of the last block downloaded
 */
protected void progress(double pct, int blocksSoFar, Date date) {
  log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar,
      Utils.dateTimeFormat(date)));
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Called when download progress is made.
 *
 * @param pct  the percentage of chain downloaded, estimated
 * @param date the date of the last block downloaded
 */
protected void progress(double pct, int blocksSoFar, Date date) {
  log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar,
      Utils.dateTimeFormat(date)));
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Called when download progress is made.
 *
 * @param pct  the percentage of chain downloaded, estimated
 * @param date the date of the last block downloaded
 */
protected void progress(double pct, int blocksSoFar, Date date) {
  log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar,
      Utils.dateTimeFormat(date)));
}

代码示例来源:origin: fr.acinq/bitcoinj-core

private void checkTimestamp() throws VerificationException {
  final long allowedTime = Utils.currentTimeSeconds() + ALLOWED_TIME_DRIFT;
  if (time > allowedTime)
    throw new VerificationException(String.format(Locale.US,
        "Block too far in future: %s (%d) vs allowed %s (%d)", Utils.dateTimeFormat(time * 1000), time,
        Utils.dateTimeFormat(allowedTime * 1000), allowedTime));
}

代码示例来源:origin: greenaddress/GreenBits

private void checkTimestamp() throws VerificationException {
  final long allowedTime = Utils.currentTimeSeconds() + ALLOWED_TIME_DRIFT;
  if (time > allowedTime)
    throw new VerificationException(String.format(Locale.US,
        "Block too far in future: %s (%d) vs allowed %s (%d)", Utils.dateTimeFormat(time * 1000), time,
        Utils.dateTimeFormat(allowedTime * 1000), allowedTime));
}

代码示例来源:origin: HashEngineering/dashj

/**
 * <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be
 * automatically respent to any key that was created after T. This can be used to recover from a situation where
 * a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero
 * as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)}
 * will create and possibly send rotation transactions: but it won't be done automatically (because you might have
 * to ask for the users password).</p>
 *
 * <p>The given time cannot be in the future.</p>
 */
public void setKeyRotationTime(long unixTimeSeconds) {
  checkArgument(unixTimeSeconds <= Utils.currentTimeSeconds(), "Given time (%s) cannot be in the future.",
      Utils.dateTimeFormat(unixTimeSeconds * 1000));
  vKeyRotationTimestamp = unixTimeSeconds;
  saveNow();
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be
 * automatically respent to any key that was created after T. This can be used to recover from a situation where
 * a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero
 * as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)}
 * will create and possibly send rotation transactions: but it won't be done automatically (because you might have
 * to ask for the users password).</p>
 *
 * <p>The given time cannot be in the future.</p>
 */
public void setKeyRotationTime(long unixTimeSeconds) {
  checkArgument(unixTimeSeconds <= Utils.currentTimeSeconds(), "Given time (%s) cannot be in the future.",
      Utils.dateTimeFormat(unixTimeSeconds * 1000));
  vKeyRotationTimestamp = unixTimeSeconds;
  saveNow();
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be
 * automatically respent to any key that was created after T. This can be used to recover from a situation where
 * a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero
 * as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)}
 * will create and possibly send rotation transactions: but it won't be done automatically (because you might have
 * to ask for the users password).</p>
 *
 * <p>The given time cannot be in the future.</p>
 */
public void setKeyRotationTime(long unixTimeSeconds) {
  checkArgument(unixTimeSeconds <= Utils.currentTimeSeconds(), "Given time (%s) cannot be in the future.",
      Utils.dateTimeFormat(unixTimeSeconds * 1000));
  vKeyRotationTimestamp = unixTimeSeconds;
  saveNow();
}

代码示例来源:origin: fr.acinq/bitcoinj-core

@Override public Void call() throws Exception {
    // Runs in an auto save thread.
    if (!savePending.getAndSet(false)) {
      // Some other scheduled request already beat us to it.
      return null;
    }
    Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
    log.info("Background saving wallet; last seen block is height {}, date {}, hash {}",
        wallet.getLastBlockSeenHeight(),
        lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
        wallet.getLastBlockSeenHash());
    saveNowInternal();
    return null;
  }
};

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

@Override public Void call() throws Exception {
    // Runs in an auto save thread.
    if (!savePending.getAndSet(false)) {
      // Some other scheduled request already beat us to it.
      return null;
    }
    Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
    log.info("Background saving wallet; last seen block is height {}, date {}, hash {}",
        wallet.getLastBlockSeenHeight(),
        lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
        wallet.getLastBlockSeenHash());
    saveNowInternal();
    return null;
  }
};

代码示例来源:origin: HashEngineering/dashj

@Override public Void call() throws Exception {
    // Runs in an auto save thread.
    if (!savePending.getAndSet(false)) {
      // Some other scheduled request already beat us to it.
      return null;
    }
    Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
    log.info("Background saving wallet; last seen block is height {}, date {}, hash {}",
        wallet.getLastBlockSeenHeight(),
        lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
        wallet.getLastBlockSeenHash());
    saveNowInternal();
    return null;
  }
};

代码示例来源:origin: greenaddress/GreenBits

@Override public Void call() throws Exception {
    // Runs in an auto save thread.
    if (!savePending.getAndSet(false)) {
      // Some other scheduled request already beat us to it.
      return null;
    }
    Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
    log.info("Background saving wallet; last seen block is height {}, date {}, hash {}",
        wallet.getLastBlockSeenHeight(),
        lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
        wallet.getLastBlockSeenHash());
    saveNowInternal();
    return null;
  }
};

代码示例来源:origin: HashEngineering/dashj

private static void setCreationTime() {
  DeterministicSeed seed = wallet.getActiveKeyChain().getSeed();
  if (seed == null) {
    System.err.println("Active chain does not have a seed.");
    return;
  }
  long creationTime = getCreationTimeSeconds();
  if (creationTime > 0)
    System.out.println("Setting creation time to: " + Utils.dateTimeFormat(creationTime * 1000));
  else
    System.out.println("Clearing creation time.");
  seed.setCreationTimeSeconds(creationTime);
}

代码示例来源:origin: greenaddress/GreenBits

/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */
public void saveNow() throws IOException {
  // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight
  // but they will serialize (using different temp files).
  Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
  log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(),
      lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
      wallet.getLastBlockSeenHash());
  saveNowInternal();
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */
public void saveNow() throws IOException {
  // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight
  // but they will serialize (using different temp files).
  Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
  log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(),
      lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
      wallet.getLastBlockSeenHash());
  saveNowInternal();
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */
public void saveNow() throws IOException {
  // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight
  // but they will serialize (using different temp files).
  Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
  log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(),
      lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
      wallet.getLastBlockSeenHash());
  saveNowInternal();
}

代码示例来源:origin: HashEngineering/dashj

/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */
public void saveNow() throws IOException {
  // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight
  // but they will serialize (using different temp files).
  if (executor.isShutdown())
    return;
  Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
  log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(),
      lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
      wallet.getLastBlockSeenHash());
  saveNowInternal();
}

代码示例来源:origin: greenaddress/GreenBits

@Test
  public void dateTimeFormat() {
    assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(1416135273781L));
    assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(new Date(1416135273781L)));
  }
}

代码示例来源:origin: HashEngineering/dashj

@Override
  public void notifyNewBestBlock(StoredBlock block) throws VerificationException {
    int height = block.getHeight();
    if (height % CoinDefinition.getIntervalCheckpoints() == 0 && block.getHeader().getTimeSeconds() <= timeAgo) {
      System.out.println(String.format("Checkpointing block %s at height %d, time %s",
          block.getHeader().getHash(), block.getHeight(), Utils.dateTimeFormat(block.getHeader().getTime())));
      checkpoints.put(height, block);
    }
  }
});

相关文章