@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; }
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"); } }
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));
assertEquals(false, DateUtils.isToday(tomorrow)); LocalDateTime todayLdt = LocalDateTime.now(); LocalDateTime yesterdayLdt = todayLdt.minusDays(1); LocalDateTime tomorrowLdt = todayLdt.plusDays(1);
@Override public LocalDateTime now() { return LocalDateTime.now(); } }
@Override protected LocalDateTime now() { return LocalDateTime.now(); }
@Override public LocalDateTime now() { return LocalDateTime.now(); } }
@Override public LocalDateTime now() { return LocalDateTime.now(); }
@Override protected LocalDateTime now() { return LocalDateTime.now(); }
/** * Starts this progress bar. */ public ProgressBar start() { progress.startTime = LocalDateTime.now(); thread.start(); return this; }
/** * Starts this progress bar. */ public ProgressBar start() { progress.startTime = LocalDateTime.now(); thread.start(); return this; }
/** * 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; }
/** * 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"); }
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)); }
@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; }
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; }
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"); } }
public static String getNowTimestampString() { LocalDateTime date = LocalDateTime.now(); String timestampString = date.toDateTime(timeZone).toInstant().toString(); return timestampString; }
@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))); }
@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)); }