本文整理匯總了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())));
}
示例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;
}
}
示例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;
}