@Override public List<WorkUnit> getWorkunits(SourceState state) { DateTimeFormatter formatter = DateTimeFormat.fullDateTime(); // Initialize all instance variables for this object init(state); LOG.info("Will pull data from " + formatter.print(this.lowWaterMark) + " until " + this.maxFilesPerJob + " files have been processed, or until there is no more data to consume"); LOG.info("Creating workunits"); // Weighted MultiWorkUnitWeightedQueue, the job will add new WorkUnits to the queue along with a weight for each // WorkUnit. The queue will take care of balancing the WorkUnits amongst a set number of MultiWorkUnits MultiWorkUnitWeightedQueue multiWorkUnitWeightedQueue = new MultiWorkUnitWeightedQueue(this.maxWorkUnitsPerJob); // Add failed work units from the previous execution addFailedWorkUnits(getPreviousWorkUnitsForRetry(this.sourceState), multiWorkUnitWeightedQueue); // If the file count has not exceeded maxFilesPerJob then start adding new WorkUnits to for this job if (this.fileCount >= this.maxFilesPerJob) { LOG.info( "The number of work units from previous job has already reached the upper limit, no more workunits will be made"); return multiWorkUnitWeightedQueue.getQueueAsList(); } addNewWorkUnits(multiWorkUnitWeightedQueue); return multiWorkUnitWeightedQueue.getQueueAsList(); }
@Override public String format(Object val, String pattern, Locale locale, String timezone) { if (!(val instanceof DateTime)) return null; DateTimeFormatter fmt; if (null != pattern) fmt = DateTimeFormat.forPattern(pattern); else fmt = DateTimeFormat.fullDateTime(); fmt = fmt.withLocale(locale); if (null != timezone) { DateTimeZone dtz = DateTimeZone.forID(timezone); fmt = fmt.withZone(dtz); } return fmt.print((DateTime)val); } }
@Override public String format(Object val, String pattern, Locale locale, String timezone) { if (!(val instanceof DateTime)) return null; DateTimeFormatter fmt; if (null != pattern) fmt = DateTimeFormat.forPattern(pattern); else fmt = DateTimeFormat.fullDateTime(); fmt = fmt.withLocale(locale); if (null != timezone) { DateTimeZone dtz = DateTimeZone.forID(timezone); fmt = fmt.withZone(dtz); } return fmt.print((DateTime)val); } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public DateTimeFormatter getDateTimeFormatter() { return DateTimeFormat.fullDateTime().withLocale(getLocales().get(0)); } }
protected void initialize(List<Expr> args, Map<String, Expr> params, Expr.NumericBinding bindings) { String format = args.size() > 1 ? Evals.getConstantString(args.get(1)).trim() : Evals.evalOptionalString(params.get("format"), bindings); String language = args.size() > 2 ? Evals.getConstantString(args.get(2)).trim() : Evals.evalOptionalString(params.get("locale"), bindings); String timezone = args.size() > 3 ? Evals.getConstantString(args.get(3)).trim() : Evals.evalOptionalString(params.get("timezone"), bindings); formatter = format == null ? DateTimeFormat.fullDateTime() : DateTimeFormat.forPattern(format); if (language != null) { formatter.withLocale(Locale.forLanguageTag(language)); } if (timezone != null) { formatter.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timezone))); } }
private static LocalDate parseAsLocalDate(String dateStr) { for (DateTimeFormatter formatter : new DateTimeFormatter[] { DateTimeFormat.fullDateTime(), DateTimeFormat.mediumDateTime(), DateTimeFormat.shortDateTime(), DateTimeFormat.forPattern("yyyy-MM-dd"), DateTimeFormat.forPattern("yyyyMMdd"), }) { try { return formatter.parseLocalDate(dateStr); } catch (Exception e) { // continue; } } return null; }
@Override protected void initialize(List<Expr> args, Map<String, Expr> params, Expr.NumericBinding bindings) { super.initialize(args, params, bindings); String format = Evals.evalOptionalString(params.get("out.format"), bindings); String language = Evals.evalOptionalString(params.get("out.locale"), bindings); String timezone = Evals.evalOptionalString(params.get("out.timezone"), bindings); outputFormat = format == null ? DateTimeFormat.fullDateTime() : DateTimeFormat.forPattern(format); if (language != null) { outputFormat.withLocale(Locale.forLanguageTag(language)); } if (timezone != null) { outputFormat.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timezone))); } }
private static LocalDate parseAsLocalDate(String dateStr) { for (DateTimeFormatter formatter : new DateTimeFormatter[] { DateTimeFormat.fullDateTime(), DateTimeFormat.mediumDateTime(), DateTimeFormat.shortDateTime(), DateTimeFormat.forPattern("yyyy-MM-dd"), DateTimeFormat.forPattern("yyyyMMdd"), }) { try { return formatter.parseLocalDate(dateStr); } catch (Exception e) { // continue; } } return null; }
private static LocalDateTime parseAsLocalDateTime(String dateStr) { for (DateTimeFormatter formatter : new DateTimeFormatter[] { DateTimeFormat.fullDateTime(), DateTimeFormat.mediumDateTime(), DateTimeFormat.shortDateTime(), DateTimeFormat.forPattern("yyyyMMddhhmmss"), DateTimeFormat.forPattern("yyyyMMddhhmm") }) { try { return formatter.parseLocalDateTime(dateStr); } catch (Exception e) { // continue; } } return null; }
private static LocalDateTime parseAsLocalDateTime(String dateStr) { for (DateTimeFormatter formatter : new DateTimeFormatter[] { DateTimeFormat.fullDateTime(), DateTimeFormat.mediumDateTime(), DateTimeFormat.shortDateTime(), DateTimeFormat.forPattern("yyyyMMddhhmmss"), DateTimeFormat.forPattern("yyyyMMddhhmm") }) { try { return formatter.parseLocalDateTime(dateStr); } catch (Exception e) { // continue; } } return null; }
final DateTimeFormatter dateTimeFormatter = StringUtils.isNotBlank(column.getDataTypeFormat()) ? DateTimeFormat.forPattern(column.getDataTypeFormat()) : DateTimeFormat.fullDateTime(); convertedValue = dateTimeFormatter.withZoneUTC() .parseDateTime(value)
@Override public List<WorkUnit> getWorkunits(SourceState state) { DateTimeFormatter formatter = DateTimeFormat.fullDateTime(); // Initialize all instance variables for this object init(state); LOG.info("Will pull data from " + formatter.print(this.lowWaterMark) + " until " + this.maxFilesPerJob + " files have been processed, or until there is no more data to consume"); LOG.info("Creating workunits"); // Weighted MultiWorkUnitWeightedQueue, the job will add new WorkUnits to the queue along with a weight for each // WorkUnit. The queue will take care of balancing the WorkUnits amongst a set number of MultiWorkUnits MultiWorkUnitWeightedQueue multiWorkUnitWeightedQueue = new MultiWorkUnitWeightedQueue(this.maxWorkUnitsPerJob); // Add failed work units from the previous execution addFailedWorkUnits(getPreviousWorkUnitsForRetry(this.sourceState), multiWorkUnitWeightedQueue); // If the file count has not exceeded maxFilesPerJob then start adding new WorkUnits to for this job if (this.fileCount >= this.maxFilesPerJob) { LOG.info( "The number of work units from previous job has already reached the upper limit, no more workunits will be made"); return multiWorkUnitWeightedQueue.getQueueAsList(); } addNewWorkUnits(multiWorkUnitWeightedQueue); return multiWorkUnitWeightedQueue.getQueueAsList(); }
DateTimeFormatter dateTimeFormatter = StringUtils.isNotEmpty(field.getTimeFormat()) ? DateTimeFormat.forPattern(field.getTimeFormat()) : DateTimeFormat.fullDateTime();
formatter = DateTimeFormat.forStyle(style); } else { formatter = DateTimeFormat.fullDateTime();