當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeUtils.currentTimeMillis方法代碼示例

本文整理匯總了Java中org.joda.time.DateTimeUtils.currentTimeMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeUtils.currentTimeMillis方法的具體用法?Java DateTimeUtils.currentTimeMillis怎麽用?Java DateTimeUtils.currentTimeMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTimeUtils的用法示例。


在下文中一共展示了DateTimeUtils.currentTimeMillis方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: RemoteDisco

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
 * Construct a new RemoteDisco - purely for testing - with an already
 * determined result. Either jid or error must be passed.
 *
 * @param remoteDomain the name of the remote domain (not JID)
 * @param jid          the domain's remote JID
 * @param error        the error from disco
 */
@VisibleForTesting
RemoteDisco(String remoteDomain, String jid, FederationError error) {
  Preconditions.checkArgument((jid != null)^(error != null));

  manager = null;
  status = new AtomicReference<Status>(Status.COMPLETE);
  pending = null;
  this.remoteDomain = remoteDomain;
  this.remoteJid = jid;
  this.error = error;
  // defaults for testing
  this.creationTimeMillis = DateTimeUtils.currentTimeMillis();
  this.failExpirySecs = 2 * 60;
  this.successExpirySecs = 2 * 60 * 60;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:24,代碼來源:RemoteDisco.java

示例2: ttlExceeded

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
 * Returns true if this RemoteDisco's time to live is exceeded.
 *
 * We can't use MapMaker's expiration code as it won't let us have different expiry for
 * successful and failed cases.
 *
 * @return whether this object should be deleted and recreated
 */
public boolean ttlExceeded() {
  if (status.get() == Status.COMPLETE) {
    if (remoteJid == null) {
      // Failed disco case
      if (DateTimeUtils.currentTimeMillis() >
          (creationTimeMillis + (1000 * failExpirySecs))) {
        return true;
      }
    } else {
      // Successful disco case
      if (DateTimeUtils.currentTimeMillis() >
          (creationTimeMillis + (1000 * successExpirySecs))) {
        return true;
      }
    }
  }
  return false;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:27,代碼來源:RemoteDisco.java

示例3: write

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Override
public void write( byte[] buffer, int off, int length ) {
    try {
        ByteBuffer b = ByteBuffer.wrap( buffer, off, length );
        long start = DateTimeUtils.currentTimeMillis();
        while( b.hasRemaining() ) {
            if( channel.write( b ) == 0 ) {
                if( DateTimeUtils.currentTimeMillis() - start > timeout )
                    throw new SocketTimeoutException( "unable to write for " + timeout + "ms" );
                Threads.sleepSafely( 10 );
            } else start = DateTimeUtils.currentTimeMillis();
        }
    } catch( IOException e ) {
        throw new UncheckedIOException( e );
    }
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:17,代碼來源:ChannelConnection.java

示例4: TimestampedEvent

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:16,代碼來源:TimestampedEvent.java

示例5: evaluate

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@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;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:31,代碼來源:CurrentTimestampFunction.java

示例6: load

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
private void load() {
    lastFsync = DateTimeUtils.currentTimeMillis();

    final Consumer<Metadata<T>> cons = metadata -> {
        val id = identifier.get( metadata.object );
        data.put( id, metadata );
    };

    log.info( "[{}] total {}", collection.getNamespace(), collection.count() );

    collection.find().forEach( cons );
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:13,代碼來源:MongoStorage.java

示例7: toHexStringLong

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void toHexStringLong() {
    assertEquals( Strings.toHexString( 0xFF000000L ), "FF000000" );
    assertEquals( Strings.toHexString( 0x10L ), "10" );
    assertEquals( Strings.toHexString( 0x101L ), "101" );
    long millis = DateTimeUtils.currentTimeMillis();
    assertEquals( Strings.toHexString( millis ), Long.toHexString( millis ).toUpperCase() );
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:9,代碼來源:StringsTest.java

示例8: isAfter

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:19,代碼來源:AbstractInterval.java

示例9: run

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Override
public void run() {
    val now = DateTimeUtils.currentTimeMillis() - expiration;
    for( val tt : storage ) {
        if( tt.time < now ) {
            storage.delete( tt.id );
        }
    }
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:10,代碼來源:DefaultTemporaryTokenService.java

示例10: merge

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@SuppressWarnings( "unchecked" )
public boolean merge( Node node ) {
    mt = DateTimeUtils.currentTimeMillis();
    if( v == null ) v = node.v;
    else {
        try {
            if( node.v != null ) v.merge( node.v );
        } catch( Throwable t ) {
            log.error( t.getMessage(), t );

            return false;
        }
    }
    return true;
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:16,代碼來源:Node.java

示例11: report

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Override
public synchronized void report( SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
                                 SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers ) {
    try {

        final long time = DateTimeUtils.currentTimeMillis();

        BatchPoints.Builder pointsBuilder = BatchPoints.database( database );

        BatchPoints points = pointsBuilder.build();

        final SortedMap<String, Point.Builder> builders = new TreeMap<>();

        reportCounters( counters, builders );
        reportMeters( meters, builders );
        reportTimers( timers, builders );
        reportGauges( gauges, builders );
        reportHistograms( histograms, builders );

        builders.values().forEach( b -> points.point( b.time( time, MILLISECONDS ).build() ) );

        logger.trace( "reporting {} counters, {} meters, {} timers, {} gauges, {} histograms",
            counters.size(), meters.size(), timers.size(), gauges.size(), histograms
        );
        influxDB.write( points );
    } catch( Exception e ) {
        Throwable rootCause = Throwables.getRootCause( e );
        if( rootCause instanceof SocketException || rootCause instanceof InterruptedIOException ) {
            logger.error( e.getMessage() );
        } else {
            logger.error( e.getMessage(), e );
        }
    }
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:35,代碼來源:InfluxDBReporter.java

示例12: currentTimeHour

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
public static long currentTimeHour() {
    return DateTimeUtils.currentTimeMillis() / 1000 / 60 / 60;
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:4,代碼來源:Dates.java

示例13: getTime

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Override
public long getTime() {
   return DateTimeUtils.currentTimeMillis();
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:5,代碼來源:JodaClock.java

示例14: run

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
public void run() {
    long current = DateTimeUtils.currentTimeMillis() - safePeriod;
    this.job.accept( lastTimeExecuted.get() );
    lastTimeExecuted.set( current );
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:6,代碼來源:PeriodicScheduled.java

示例15: currentTimeDay

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
public static long currentTimeDay() {
    return DateTimeUtils.currentTimeMillis() / 1000 / 60 / 60 / 24;
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:4,代碼來源:Dates.java


注:本文中的org.joda.time.DateTimeUtils.currentTimeMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。