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


Java LocalDateTime.now方法代碼示例

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


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

示例1: testThatEpochTimePrinterWorks

import org.joda.time.LocalDateTime; //導入方法依賴的package包/類
public void testThatEpochTimePrinterWorks() {
    StringBuffer buffer = new StringBuffer();
    LocalDateTime now = LocalDateTime.now();

    Joda.EpochTimePrinter epochTimePrinter = new Joda.EpochTimePrinter(false);
    epochTimePrinter.printTo(buffer, now, Locale.ROOT);
    assertThat(buffer.length(), is(10));
    // only check the last digit, as seconds go from 0-99 in the unix timestamp and don't stop at 60
    assertThat(buffer.toString(), endsWith(String.valueOf(now.getSecondOfMinute() % 10)));

    buffer = new StringBuffer();
    Joda.EpochTimePrinter epochMilliSecondTimePrinter = new Joda.EpochTimePrinter(true);
    epochMilliSecondTimePrinter.printTo(buffer, now, Locale.ROOT);
    assertThat(buffer.length(), is(13));
    assertThat(buffer.toString(), endsWith(String.valueOf(now.getMillisOfSecond())));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:SimpleJodaTests.java

示例2: getExpiryStatus

import org.joda.time.LocalDateTime; //導入方法依賴的package包/類
public CertificateExpiryStatus getExpiryStatus(Duration warningPeriod) {
    try {
        Date notAfter = getNotAfter();
        LocalDateTime now = LocalDateTime.now();
        Date notBefore = getNotBefore();
        if (now.toDate().after(notAfter) || now.toDate().before(notBefore)) {
            return CertificateExpiryStatus.CRITICAL;
        }
        if (now.plus(warningPeriod).toDate().after(notAfter)) {
            return CertificateExpiryStatus.WARNING;
        }
        return CertificateExpiryStatus.OK;
    } catch (CertificateException e) {
        return CertificateExpiryStatus.CRITICAL;
    }
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:17,代碼來源:Certificate.java

示例3: generateData

import org.joda.time.LocalDateTime; //導入方法依賴的package包/類
private String generateData(boolean printHeader, boolean longTimestamp, String Timezone, String dataFormat)
{
    LocalDateTime queryTime = LocalDateTime.now();

    if(isTest)
        queryTime = LocalDateTime.parse("2016-01-01T00:00:00.000");

    // Get the time Values for the current time
    scala.collection.Iterable<Tuple3<String, LocalDateTime, Object>> data = SimController.getTimeValue(simConfig.timeSeries(), queryTime);

    // Convert the Scala Iterable to a Java one
    Iterable<Tuple3<String, LocalDateTime, Object>> generatedValues = JavaConverters.asJavaIterableConverter(data).asJava();

    String resultString = "";

    if (dataFormat.equals("CSV")){
        resultString = createCsv(printHeader, longTimestamp, Timezone, generatedValues);
    }
    else if (dataFormat.equals("JSON")){
        resultString = generateJson(longTimestamp, Timezone, generatedValues);
    }

    return resultString;
}
 
開發者ID:hashmapinc,項目名稱:nifi-simulator-bundle,代碼行數:25,代碼來源:GenerateTimeSeriesFlowFile.java


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