org.joda.time.DateTime.now()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(273)

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

DateTime.now介绍

[英]Obtains a DateTime set to the current system millisecond time using ISOChronology in the default time zone.
[中]使用默认时区中的ISOChronology获取设置为当前系统毫秒时间的日期时间。

代码示例

代码示例来源:origin: prestodb/presto

public void recordHeartbeat()
{
  lastHeartbeat.set(DateTime.now());
}

代码示例来源:origin: prestodb/presto

public void startProcessTimer()
{
  if (startNanos.compareAndSet(0, System.nanoTime())) {
    pipelineContext.start();
    executionStartTime.set(DateTime.now());
  }
}

代码示例来源:origin: prestodb/presto

public void start()
{
  DateTime now = DateTime.now();
  executionStartTime.compareAndSet(null, now);
  // always update last execution start time
  lastExecutionStartTime.set(now);
  taskContext.start();
}

代码示例来源:origin: prestodb/presto

public synchronized boolean transitionToScheduled()
{
  schedulingComplete.compareAndSet(null, DateTime.now());
  return stageState.setIf(SCHEDULED, currentState -> currentState == PLANNED || currentState == SCHEDULING || currentState == SCHEDULING_SPLITS);
}

代码示例来源:origin: prestodb/presto

public void finished()
{
  if (!finished.compareAndSet(false, true)) {
    // already finished
    return;
  }
  executionEndTime.set(DateTime.now());
  endNanos.set(System.nanoTime());
  pipelineContext.driverFinished(this);
}

代码示例来源:origin: apache/incubator-druid

public static DateTime nowUtc()
{
 return DateTime.now(ISOChronology.getInstanceUTC());
}

代码示例来源:origin: prestodb/presto

/**
 * For each request, the addPage method will be called zero or more times,
 * followed by either requestComplete or clientFinished (if buffer complete).  If the client is
 * closed, requestComplete or bufferFinished may never be called.
 * <p/>
 * <b>NOTE:</b> Implementations of this interface are not allowed to perform
 * blocking operations.
 */
public interface ClientCallback
{
  boolean addPages(HttpPageBufferClient client, List<SerializedPage> pages);
  void requestComplete(HttpPageBufferClient client);
  void clientFinished(HttpPageBufferClient client);
  void clientFailed(HttpPageBufferClient client, Throwable cause);
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
public IndexRange createUnknownRange(String index) {
  final DateTime begin = new DateTime(0L, DateTimeZone.UTC);
  final DateTime end = new DateTime(0L, DateTimeZone.UTC);
  final DateTime now = DateTime.now(DateTimeZone.UTC);
  return MongoIndexRange.create(index, begin, end, now, 0);
}

代码示例来源:origin: prestodb/presto

public void start()
{
  DateTime now = DateTime.now();
  executionStartTime.compareAndSet(null, now);
  startNanos.compareAndSet(0, System.nanoTime());
  startFullGcCount.compareAndSet(-1, gcMonitor.getMajorGcCount());
  startFullGcTimeNanos.compareAndSet(-1, gcMonitor.getMajorGcTime().roundTo(NANOSECONDS));
  // always update last execution start time
  lastExecutionStartTime.set(now);
}

代码示例来源:origin: prestodb/presto

@Override
public void onSuccess(@Nullable StatusResponse result)
{
  checkNotHoldsLock(this);
  backoff.success();
  synchronized (HttpPageBufferClient.this) {
    closed = true;
    if (future == resultFuture) {
      future = null;
    }
    lastUpdate = DateTime.now();
  }
  requestsCompleted.incrementAndGet();
  clientCallback.clientFinished(HttpPageBufferClient.this);
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
  public boolean test(Sidecar sidecar) {
    final DateTime threshold = DateTime.now(DateTimeZone.UTC).minus(timeoutPeriod);
    return sidecar.lastSeen().isAfter(threshold);
  }
}

代码示例来源:origin: prestodb/presto

private synchronized void initiateRequest()
{
  scheduled = false;
  if (closed || (future != null)) {
    return;
  }
  if (completed) {
    sendDelete();
  }
  else {
    sendGetResults();
  }
  lastUpdate = DateTime.now();
}

代码示例来源:origin: prestodb/presto

private boolean isAbandoned(T query)
{
  DateTime oldestAllowedHeartbeat = DateTime.now().minus(clientTimeout.toMillis());
  DateTime lastHeartbeat = query.getLastHeartbeat();
  return lastHeartbeat != null && lastHeartbeat.isBefore(oldestAllowedHeartbeat);
}

代码示例来源:origin: Graylog2/graylog2-server

public static ClusterEvent create(@NotEmpty String producer,
                   @NotEmpty String eventClass,
                   @NotEmpty Object payload) {
    return create(null,
        DateTime.now(DateTimeZone.UTC).getMillis(),
        producer,
        Collections.<String>emptySet(),
        eventClass,
        payload);
  }
}

代码示例来源:origin: prestodb/presto

public static TaskInfo createInitialTask(TaskId taskId, URI location, String nodeId, List<BufferInfo> bufferStates, TaskStats taskStats)
{
  return new TaskInfo(
      initialTaskStatus(taskId, location, nodeId),
      DateTime.now(),
      new OutputBufferInfo("UNINITIALIZED", OPEN, true, true, 0, 0, 0, 0, bufferStates),
      ImmutableSet.of(),
      taskStats,
      true);
}

代码示例来源:origin: prestodb/presto

/**
 * Perform a sanity check to make sure that the year is reasonably current, to guard against
 * issues in third party libraries.
 */
public static void verifySystemTimeIsReasonable()
{
  int currentYear = DateTime.now().year().get();
  if (currentYear < 2019) {
    failRequirement("Presto requires the system time to be current (found year %s)", currentYear);
  }
}

代码示例来源:origin: prestodb/presto

private static boolean isLeaked(Map<QueryId, BasicQueryInfo> queryIdToInfo, QueryId queryId)
{
  BasicQueryInfo queryInfo = queryIdToInfo.get(queryId);
  if (queryInfo == null) {
    return true;
  }
  DateTime queryEndTime = queryInfo.getQueryStats().getEndTime();
  if (queryInfo.getState() == RUNNING || queryEndTime == null) {
    return false;
  }
  return secondsBetween(queryEndTime, now()).getSeconds() >= DEFAULT_LEAK_CLAIM_DELTA_SEC;
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void fromMethodNameTwoPathVariables() {
  DateTime now = DateTime.now();
  UriComponents uriComponents = fromMethodName(
      ControllerWithMethods.class, "methodWithTwoPathVariables", 1, now).build();
  assertThat(uriComponents.getPath(), is("/something/1/foo/" + ISODateTimeFormat.date().print(now)));
}

代码示例来源:origin: apache/incubator-druid

@Test
 public void testSerialization() throws Exception
 {
  Interval interval = new Interval(DateTime.now(DateTimeZone.UTC), DateTime.now(DateTimeZone.UTC));
  String version = "someversion";

  CustomVersioningPolicy policy = new CustomVersioningPolicy(version);

  CustomVersioningPolicy serialized = ServerTestHelper.MAPPER.readValue(
    ServerTestHelper.MAPPER.writeValueAsBytes(policy),
    CustomVersioningPolicy.class
  );

  Assert.assertEquals(version, policy.getVersion(interval));
  Assert.assertEquals(version, serialized.getVersion(interval));
 }
}

代码示例来源:origin: prestodb/presto

private TaskStats getTaskStats(TaskHolder taskHolder)
{
  TaskInfo finalTaskInfo = taskHolder.getFinalTaskInfo();
  if (finalTaskInfo != null) {
    return finalTaskInfo.getStats();
  }
  SqlTaskExecution taskExecution = taskHolder.getTaskExecution();
  if (taskExecution != null) {
    return taskExecution.getTaskContext().getTaskStats();
  }
  // if the task completed without creation, set end time
  DateTime endTime = taskStateMachine.getState().isDone() ? DateTime.now() : null;
  return new TaskStats(taskStateMachine.getCreatedTime(), endTime);
}

相关文章

DateTime类方法