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

x33g5p2x  于2022-01-23 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(211)

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

LocalDateTime.now介绍

[英]Obtains a LocalDateTime set to the current system millisecond time using ISOChronology in the default time zone. The resulting object does not use the zone.
[中]使用默认时区中的ISOChronology获取设置为当前系统毫秒时间的LocalDateTime。生成的对象不使用分区。

代码示例

代码示例来源:origin: apache/flume

@Override
public File nextFile() {
 StringBuilder sb = new StringBuilder();
 String date = formatter.print(LocalDateTime.now());
 if (!date.equals(lastRoll)) {
  getFileIndex().set(0);
  lastRoll = date;
 }
 sb.append(getPrefix()).append(date).append("-");
 sb.append(getFileIndex().incrementAndGet());
 if (getExtension().length() > 0) {
  sb.append(".").append(getExtension());
 }
 currentFile = new File(getBaseDirectory(), sb.toString());
 return currentFile;
}

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

public TimeAwareRecursiveCopyableDataset(FileSystem fs, Path rootPath, Properties properties, Path glob) {
 super(fs, rootPath, properties, glob);
 this.lookbackTime = properties.getProperty(LOOKBACK_TIME_KEY);
 PeriodFormatter periodFormatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d").appendHours().appendSuffix("h").toFormatter();
 this.lookbackPeriod = periodFormatter.parsePeriod(lookbackTime);
 this.datePattern = properties.getProperty(DATE_PATTERN_KEY);
 this.isPatternHourly = isDatePatternHourly(datePattern);
 this.currentTime = properties.containsKey(DATE_PATTERN_TIMEZONE_KEY) ? LocalDateTime.now(
   DateTimeZone.forID(DATE_PATTERN_TIMEZONE_KEY))
   : LocalDateTime.now(DateTimeZone.forID(DEFAULT_DATE_PATTERN_TIMEZONE));
 //Daily directories cannot have a "hourly" lookback pattern. But hourly directories can accept lookback pattern with days.
 if (!this.isPatternHourly) {
  Assert.assertTrue(isLookbackTimeStringDaily(this.lookbackTime), "Expected day format for lookback time; found hourly format");
 }
}

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

DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
LocalDateTime endDate = LocalDateTime.now(DateTimeZone.forID(TimeAwareRecursiveCopyableDataset.DEFAULT_DATE_PATTERN_TIMEZONE));
endDate = LocalDateTime.now(DateTimeZone.forID(TimeAwareRecursiveCopyableDataset.DEFAULT_DATE_PATTERN_TIMEZONE));

代码示例来源:origin: dlew/joda-time-android

assertEquals(false, DateUtils.isToday(tomorrow));
LocalDateTime todayLdt = LocalDateTime.now();
LocalDateTime yesterdayLdt = todayLdt.minusDays(1);
LocalDateTime tomorrowLdt = todayLdt.plusDays(1);

代码示例来源:origin: actframework/actframework

@Override
  public LocalDateTime now() {
    return LocalDateTime.now();
  }
}

代码示例来源:origin: actframework/actframework

@Override
protected LocalDateTime now() {
  return LocalDateTime.now();
}

代码示例来源:origin: org.actframework/act

@Override
  public LocalDateTime now() {
    return LocalDateTime.now();
  }
}

代码示例来源:origin: com.vlkan.rfos/rotating-fos

@Override
public LocalDateTime now() {
  return LocalDateTime.now();
}

代码示例来源:origin: org.actframework/act

@Override
protected LocalDateTime now() {
  return LocalDateTime.now();
}

代码示例来源:origin: actframework/actframework

/**
 * Starts this progress bar.
 */
public ProgressBar start() {
  progress.startTime = LocalDateTime.now();
  thread.start();
  return this;
}

代码示例来源:origin: org.actframework/act

/**
 * Starts this progress bar.
 */
public ProgressBar start() {
  progress.startTime = LocalDateTime.now();
  thread.start();
  return this;
}

代码示例来源:origin: com.hp.autonomy.hod/java-hod-client

/**
 * Creates a new PollingJobStatusRunnable using the given token proxy
 * @param tokenProxy The token proxy used to submit the job
 * @param jobId The ID of the job
 * @param callback The callback that will be called with the result
 * @param executorService The executor service responsible for running the runnable
 */
public PollingJobStatusRunnable(final TokenProxy<?, TokenType.Simple> tokenProxy, final Duration timeout, final JobId jobId, final HodJobCallback<T> callback, final ScheduledExecutorService executorService, final JobService<? extends JobStatus<T>> jobService) {
  this.tokenProxy = tokenProxy;
  this.jobId = jobId;
  this.callback = callback;
  this.executorService = executorService;
  this.jobService = jobService;
  this.timeout = timeout != null ? LocalDateTime.now().plus(timeout) : null;
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

/**
 * As per <a href="http://pology.nedohodnik.net/doc/user/en_US/ch-poformat.html">section 2.6</a>.
 */
protected void header(final StringBuilder buf) {
  final String createdAt = LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss+Z");
  buf.append("#, fuzzy").append("\n");
  buf.append("msgid \"\"").append("\n");
  buf.append("msgstr \"\"").append("\n");
  buf.append("\"Project-Id-Version: \\n\"").append("\n");
  buf.append("\"POT-Creation-Date: ").append(createdAt).append("\\n\"").append("\n");
  buf.append("\"MIME-Version: 1.0\\n\"").append("\n");
  buf.append("\"Content-Type: text/plain; charset=UTF-8\\n\"").append("\n");
  buf.append("\"Content-Transfer-Encoding: 8bit\\n\"").append("\n");
  buf.append("\"Plural-Forms: nplurals=2; plural=n != 1;\\n\"").append("\n");
  buf.append("\n\n");
}

代码示例来源:origin: com.github.blasd.apex/apex-java

public ApexMetricsTowerControl(IApexThreadDumper apexThreadDumper) {
  this.apexThreadDumper = apexThreadDumper;
  activeTasks = CacheBuilder.newBuilder()
      .expireAfterAccess(CACHE_TIMEOUT_MINUTES, TimeUnit.MINUTES)
      .maximumSize(CACHE_MAX_SIZE)
      .concurrencyLevel(ApexExecutorsHelper.DEFAULT_ACTIVE_TASKS)
      .removalListener(this::onActiveTaskRemoval)
      .build(CacheLoader.from(key -> LocalDateTime.now()));
  verySlowTasks = CacheBuilder.newBuilder()
      .expireAfterAccess(CACHE_TIMEOUT_MINUTES, TimeUnit.MINUTES)
      .maximumSize(CACHE_MAX_SIZE)
      .concurrencyLevel(ApexExecutorsHelper.DEFAULT_ACTIVE_TASKS)
      .build(CacheLoader.from(startEvent -> startEvent));
}

代码示例来源:origin: org.apache.flume/flume-ng-core

@Override
public File nextFile() {
 StringBuilder sb = new StringBuilder();
 String date = formatter.print(LocalDateTime.now());
 if (!date.equals(lastRoll)) {
  getFileIndex().set(0);
  lastRoll = date;
 }
 sb.append(getPrefix()).append(date).append("-");
 sb.append(getFileIndex().incrementAndGet());
 if (getExtension().length() > 0) {
  sb.append(".").append(getExtension());
 }
 currentFile = new File(getBaseDirectory(), sb.toString());
 return currentFile;
}

代码示例来源:origin: kiselev-dv/gazetteer

public static JSONObject createFeature(String id, String type,
    Map<String, String> attributes, Geometry g, JSONObject meta) {
  JSONObject feature = new JSONFeature();
  
  if(id != null) {
    feature.put("id", id);
  }
  
  feature.put("ftype", type);
  feature.put(GEOJSON_TYPE_KEY, GEOJSON_TYPE_VAL);
  feature.put(GEOMETRY, geometryToJSON(g));
  feature.put(PROPERTIES, attributes);
  feature.put(META, meta);
  
  feature.put(TIMESTAMP, LocalDateTime.now().toDateTime(timeZone).toInstant().toString());
  
  return feature;
}

代码示例来源:origin: org.apache.gobblin/gobblin-data-management

public TimeAwareRecursiveCopyableDataset(FileSystem fs, Path rootPath, Properties properties, Path glob) {
 super(fs, rootPath, properties, glob);
 this.lookbackTime = properties.getProperty(LOOKBACK_TIME_KEY);
 PeriodFormatter periodFormatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d").appendHours().appendSuffix("h").toFormatter();
 this.lookbackPeriod = periodFormatter.parsePeriod(lookbackTime);
 this.datePattern = properties.getProperty(DATE_PATTERN_KEY);
 this.isPatternHourly = isDatePatternHourly(datePattern);
 this.currentTime = properties.containsKey(DATE_PATTERN_TIMEZONE_KEY) ? LocalDateTime.now(
   DateTimeZone.forID(DATE_PATTERN_TIMEZONE_KEY))
   : LocalDateTime.now(DateTimeZone.forID(DEFAULT_DATE_PATTERN_TIMEZONE));
 //Daily directories cannot have a "hourly" lookback pattern. But hourly directories can accept lookback pattern with days.
 if (!this.isPatternHourly) {
  Assert.assertTrue(isLookbackTimeStringDaily(this.lookbackTime), "Expected day format for lookback time; found hourly format");
 }
}

代码示例来源:origin: kiselev-dv/gazetteer

public static String getNowTimestampString() {
  LocalDateTime date = LocalDateTime.now();
  String timestampString = date.toDateTime(timeZone).toInstant().toString();
  return timestampString;
}

代码示例来源:origin: org.apache.isis.core/isis-core-metamodel

@Test
public void roundtrip() throws Exception {
  final LocalDateTime t0 = LocalDateTime.now();
  final String encoded = provider.doEncode(t0);
  final LocalDateTime t1 = provider.doRestore(encoded);
  assertThat(t0, is(equalTo(t1)));
}

代码示例来源:origin: org.apache.isis.core/isis-core-applib

@Test
public void roundTripLocalDateTime() throws Exception {
  // given
  final LocalDateTime value = LocalDateTime.now();
  // when
  executionParameters.setParameter("test", value);
  final LocalDateTime roundTripped = executionParameters.getParameterAsLocalDateTime("test");
  final LocalDateTime roundTrippedAsT = executionParameters.getParameterAsT("test", LocalDateTime.class);
  // then
  assertThat(roundTripped, is(value));
  assertThat(roundTrippedAsT, is(value));
}

相关文章