org.joda.time.DateTimeUtils#currentTimeMillis ( )源码实例Demo

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

源代码1 项目: ns4_gear_watchdog   文件: TimestampedEvent.java
public TimestampedEvent(Event base) {
  setBody(base.getBody());
  Map<String, String> headers = Maps.newHashMap(base.getHeaders());
  String timestampString = headers.get("timestamp");
  if (StringUtils.isBlank(timestampString)) {
    timestampString = headers.get("@timestamp");
  }
  if (StringUtils.isBlank(timestampString)) {
    this.timestamp = DateTimeUtils.currentTimeMillis();
    headers.put("timestamp", String.valueOf(timestamp));
  } else {
    this.timestamp = Long.valueOf(timestampString);
  }
  setHeaders(headers);
}
 
源代码2 项目: gocd   文件: SCMMaterialSource.java
boolean hasUpdateIntervalElapsedForScmMaterial(Material material) {
    Long lastMaterialUpdateTime = materialLastUpdateTimeMap.get(material);
    if (lastMaterialUpdateTime != null) {
        boolean shouldUpdateMaterial = (DateTimeUtils.currentTimeMillis() - lastMaterialUpdateTime) >= materialUpdateInterval;
        if (LOGGER.isDebugEnabled() && !shouldUpdateMaterial) {
            LOGGER.debug("[Material Update] Skipping update of material {} which has been last updated at {}", material, new Date(lastMaterialUpdateTime));
        }
        return shouldUpdateMaterial;
    }
    return true;
}
 
源代码3 项目: Elasticsearch   文件: CurrentTimestampFunction.java
@Override
public Long evaluate(Input<Integer>... args) {
    long millis = DateTimeUtils.currentTimeMillis();
    if (args.length == 1) {
        Integer precision = args[0].value();
        if (precision == null) {
            throw new IllegalArgumentException(String.format(Locale.ENGLISH,
                    "NULL precision not supported for %s", NAME));
        }
        int factor;
        switch (precision) {
            case 0:
                factor = 1000;
                break;
            case 1:
                factor = 100;
                break;
            case 2:
                factor = 10;
                break;
            case 3:
                factor = 1;
                break;
            default:
                throw new IllegalArgumentException("Precision must be between 0 and 3");
        }
        millis = LongMath.divide(millis, factor, RoundingMode.DOWN) * factor;
    }
    return millis;
}
 
源代码4 项目: ElasticsearchSink2   文件: TimestampedEvent.java
TimestampedEvent(Event base) {
  setBody(base.getBody());
  Map<String, String> headers = Maps.newHashMap(base.getHeaders());
  String timestampString = headers.get("timestamp");
  if (StringUtils.isBlank(timestampString)) {
    timestampString = headers.get("@timestamp");
  }
  if (StringUtils.isBlank(timestampString)) {
    this.timestamp = DateTimeUtils.currentTimeMillis();
    headers.put("timestamp", String.valueOf(timestamp ));
  } else {
    this.timestamp = Long.valueOf(timestampString);
  }
  setHeaders(headers);
}
 
源代码5 项目: hdfs2cass   文件: ThriftByFieldNamesFn.java
private long getTimestamp(final T input) {
  if (timestampIndex > -1) {
    Object value = input.get(timestampIndex);
    if (value instanceof Long) {
      return (long) value;
    } else {
      throw new CrunchRuntimeException("Can not transform timestamp field (class: " + value.getClass() + ") to long");
    }
  } else {
    return DateTimeUtils.currentTimeMillis();
  }
}
 
源代码6 项目: astor   文件: AbstractInterval.java
/**
 * Is this time interval entirely after the specified interval.
 * <p>
 * Intervals are inclusive of the start instant and exclusive of the end.
 * Only the end time of the specified interval is used in the comparison.
 * 
 * @param interval  the interval to compare to, null means now
 * @return true if this time interval is after the interval specified
 */
public boolean isAfter(ReadableInterval interval) {
    long endMillis;
    if (interval == null) {
        endMillis = DateTimeUtils.currentTimeMillis();
    } else {
        endMillis = interval.getEndMillis();
    }
    return (getStartMillis() >= endMillis);
}
 
源代码7 项目: crate   文件: CoordinatorTxnCtx.java
/**
 * @return current timestamp in ms. Subsequent calls will always return the same value. (Not thread-safe)
 */
@Override
public long currentTimeMillis() {
    if (currentTimeMillis == null) {
        // no synchronization because StmtCtx is mostly used during single-threaded analysis phase
        currentTimeMillis = DateTimeUtils.currentTimeMillis();
    }
    return currentTimeMillis;
}
 
@Test
public void selectCurrentTimestamp() throws Exception {
    long before = DateTimeUtils.currentTimeMillis();
    SQLResponse response = execute("select current_timestamp from sys.cluster");
    long after = DateTimeUtils.currentTimeMillis();
    assertThat(response.cols(), arrayContaining("current_timestamp(3)"));
    assertThat((long) response.rows()[0][0], allOf(greaterThanOrEqualTo(before), lessThanOrEqualTo(after)));
}
 
源代码9 项目: mireka   文件: Srs.java
private String calculateTimestamp() {
    int daysSinceEpoch =
            (int) (DateTimeUtils.currentTimeMillis() / 1000 / 24 / 60 / 60);
    int modulo1 = daysSinceEpoch % (2 << 10);
    int modulo = modulo1;
    return Base32Int.encode10Bits(modulo);
}
 
源代码10 项目: ingestion   文件: TimestampedEvent.java
TimestampedEvent(Event base) {
  setBody(base.getBody());
  Map<String, String> headers = Maps.newHashMap(base.getHeaders());
  String timestampString = headers.get("timestamp");
  if (StringUtils.isBlank(timestampString)) {
    timestampString = headers.get("@timestamp");
  }
  if (StringUtils.isBlank(timestampString)) {
    this.timestamp = DateTimeUtils.currentTimeMillis();
    headers.put("timestamp", String.valueOf(timestamp ));
  } else {
    this.timestamp = Long.valueOf(timestampString);
  }
  setHeaders(headers);
}
 
源代码11 项目: astor   文件: BaseInterval.java
/**
 * Constructs an interval from a start and end instant.
 * 
 * @param start  start of this interval, null means now
 * @param end  end of this interval, null means now
 * @throws IllegalArgumentException if the end is before the start
 */
protected BaseInterval(ReadableInstant start, ReadableInstant end) {
    super();
    if (start == null && end == null) {
        iStartMillis = iEndMillis = DateTimeUtils.currentTimeMillis();
        iChronology = ISOChronology.getInstance();
    } else {
        iChronology = DateTimeUtils.getInstantChronology(start);
        iStartMillis = DateTimeUtils.getInstantMillis(start);
        iEndMillis = DateTimeUtils.getInstantMillis(end);
        checkInterval(iStartMillis, iEndMillis);
    }
}
 
源代码12 项目: camunda-bpm-platform   文件: ClockUtil.java
public static Date resetClock() {
  DateTimeUtils.setCurrentMillisSystem();
  return new Date(DateTimeUtils.currentTimeMillis());
}
 
源代码13 项目: Elasticsearch   文件: BaseDateTime.java
/**
 * Constructs an instance set to the current system millisecond time
 * using <code>ISOChronology</code> in the default time zone.
 */
public BaseDateTime() {
    this(DateTimeUtils.currentTimeMillis(), ISOChronology.getInstance());
}
 
源代码14 项目: Elasticsearch   文件: BaseDateTime.java
/**
 * Constructs an instance set to the current system millisecond time
 * using <code>ISOChronology</code> in the specified time zone.
 * <p>
 * If the specified time zone is null, the default zone is used.
 *
 * @param zone the time zone, null means default zone
 */
public BaseDateTime(DateTimeZone zone) {
    this(DateTimeUtils.currentTimeMillis(), ISOChronology.getInstance(zone));
}
 
源代码15 项目: Elasticsearch   文件: BaseDateTime.java
/**
 * Constructs an instance set to the current system millisecond time
 * using the specified chronology.
 * <p>
 * If the chronology is null, <code>ISOChronology</code>
 * in the default time zone is used.
 *
 * @param chronology the chronology, null means ISOChronology in default zone
 */
public BaseDateTime(Chronology chronology) {
    this(DateTimeUtils.currentTimeMillis(), chronology);
}
 
源代码16 项目: camunda-bpm-platform   文件: ClockUtil.java
/**
 * Moves the clock by the given offset and keeps it running from that point
 * on.
 * 
 * @param offsetInMillis
 *          the offset to move the clock by
 * @return the new 'now'
 */
public static Date offset(Long offsetInMillis) {
  DateTimeUtils.setCurrentMillisOffset(offsetInMillis);
  return new Date(DateTimeUtils.currentTimeMillis());
}
 
源代码17 项目: astor   文件: AbstractConverter.java
/**
 * Extracts the millis from an object of this convertor's type.
 * <p>
 * This implementation returns the current time.
 * 
 * @param object  the object to convert
 * @param chrono  the chronology to use, which is always non-null
 * @return the millisecond value
 */
public long getInstantMillis(Object object, Chronology chrono) {
    return DateTimeUtils.currentTimeMillis();
}
 
源代码18 项目: astor   文件: BasePartial.java
/**
 * Constructs a partial with the current time, using ISOChronology in
 * the default zone to extract the fields.
 * <p>
 * The constructor uses the default time zone, resulting in the local time
 * being initialised. Once the constructor is complete, all further calculations
 * are performed without reference to a timezone (by switching to UTC).
 */
protected BasePartial() {
    this(DateTimeUtils.currentTimeMillis(), null);
}
 
源代码19 项目: astor   文件: BasePartial.java
/**
 * Constructs a partial with the current time, using the specified chronology
 * and zone to extract the fields.
 * <p>
 * The constructor uses the time zone of the chronology specified.
 * Once the constructor is complete, all further calculations are performed
 * without reference to a timezone (by switching to UTC).
 *
 * @param chronology  the chronology, null means ISOChronology in the default zone
 */
protected BasePartial(Chronology chronology) {
    this(DateTimeUtils.currentTimeMillis(), chronology);
}
 
源代码20 项目: astor   文件: BaseDateTime.java
/**
 * Constructs an instance set to the current system millisecond time
 * using <code>ISOChronology</code> in the specified time zone.
 * <p>
 * If the specified time zone is null, the default zone is used.
 *
 * @param zone  the time zone, null means default zone
 */
public BaseDateTime(DateTimeZone zone) {
    this(DateTimeUtils.currentTimeMillis(), ISOChronology.getInstance(zone));
}