List of usage examples for org.joda.time.format ISODateTimeFormat dateTime
public static DateTimeFormatter dateTime()
From source file:com.microsoft.rest.serializer.DateTimeSerializer.java
License:Open Source License
@Override public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) { jgen.writeNumber(value.getMillis()); } else {/*from w w w . j a va 2s . co m*/ value = value.withZone(DateTimeZone.UTC); jgen.writeString(value.toString(ISODateTimeFormat.dateTime())); } }
From source file:com.nesscomputing.syslog4j.server.impl.event.structured.StructuredSyslogServerEvent.java
License:Open Source License
public DateTimeFormatter getDateTimeFormatter() { if (dateTimeFormatter == null) { this.dateTimeFormatter = ISODateTimeFormat.dateTime(); }/*from w ww . j a va 2s. co m*/ return dateTimeFormatter; }
From source file:com.nfsdb.journal.lang.JournalEntryPrinter.java
License:Apache License
public void print(JournalEntry e) throws IOException { for (int i = 0; i < e.partition.getJournal().getMetadata().getColumnCount(); i++) { ColumnMetadata m = e.partition.getJournal().getMetadata().getColumnMetadata(i); switch (m.type) { case DATE: out.write(ISODateTimeFormat.dateTime().print(e.getLong(i)).getBytes()); break; case DOUBLE: out.write(Double.toString(e.getDouble(i)).getBytes()); break; case INT: out.write(Integer.toString(e.getInt(i)).getBytes()); break; case STRING: out.write(e.getStr(i).getBytes()); break; case SYMBOL: out.write(e.getSym(i).getBytes()); }/*from w w w . j a va 2 s. com*/ out.write("\t".getBytes()); } if (e.slave != null) { print(e.slave); } else { out.write("\n".getBytes()); } }
From source file:com.nfsdb.journal.printer.converter.DateConverter.java
License:Apache License
public DateConverter(JournalPrinter printer) { super(printer); this.dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC(); }
From source file:com.palantir.lock.impl.LockServiceImpl.java
License:Open Source License
private String getRequestDescription(LockRequest request) { StringBuilder builder = new StringBuilder(); builder.append("\twaiting to lock() ").append(request); builder.append(" starting at ").append(ISODateTimeFormat.dateTime().print(DateTime.now())); builder.append("\n\tfor requesting thread\n\t\t"); builder.append(request.getCreatingThreadName()).append("\n"); return builder.toString(); }
From source file:com.payintech.smoney.toolbox.JodaDateTimeConverter.java
License:Open Source License
/** * Build a converter instance with a specific format. * * @param pattern Pattern respecting the {@code Joda.DateTimeFormatter} syntax. * @see DateTimeFormatter/*from ww w . j av a 2 s. co m*/ * @since 15.11 */ public JodaDateTimeConverter(final String pattern) { this.formatter = DateTimeFormat.forPattern(pattern); this.isoFormatter = ISODateTimeFormat.dateTime(); }
From source file:com.pinterest.deployservice.handler.DeployHandler.java
License:Apache License
public List<DeployBean> getDeployCandidates(String envId, Interval interval, int size, boolean onlyGoodBuilds) throws Exception { LOG.info("Search Deploy candidates between {} and {} for environment {}", interval.getStart().toString(ISODateTimeFormat.dateTime()), interval.getEnd().toString(ISODateTimeFormat.dateTime()), envId); List<DeployBean> taggedGoodDeploys = new ArrayList<DeployBean>(); List<DeployBean> availableDeploys = deployDAO.getAcceptedDeploys(envId, interval, size); if (!onlyGoodBuilds) { return availableDeploys; }/*from w w w .ja v a2 s .c o m*/ if (!availableDeploys.isEmpty()) { Map<String, DeployBean> buildId2DeployBean = new HashMap<String, DeployBean>(); for (DeployBean deployBean : availableDeploys) { String buildId = deployBean.getBuild_id(); if (StringUtils.isNotEmpty(buildId)) { buildId2DeployBean.put(buildId, deployBean); } } List<BuildBean> availableBuilds = buildDAO.getBuildsFromIds(buildId2DeployBean.keySet()); List<BuildTagBean> buildTagBeanList = buildTagsManager.getEffectiveTagsWithBuilds(availableBuilds); for (BuildTagBean buildTagBean : buildTagBeanList) { if (buildTagBean.getTag() != null && buildTagBean.getTag().getValue() == TagValue.BAD_BUILD) { // bad build, do not include LOG.info("Env {} Build {} is tagged as BAD_BUILD, ignore", envId, buildTagBean.getBuild()); } else { String buildId = buildTagBean.getBuild().getBuild_id(); taggedGoodDeploys.add(buildId2DeployBean.get(buildId)); } } } // should order deploy bean by start date desc if (taggedGoodDeploys.size() > 0) { Collections.sort(taggedGoodDeploys, new Comparator<DeployBean>() { @Override public int compare(final DeployBean d1, final DeployBean d2) { return Long.compare(d2.getStart_date(), d1.getStart_date()); } }); LOG.info("Env {} the first deploy candidate is {}", envId, taggedGoodDeploys.get(0).getBuild_id()); } return taggedGoodDeploys; }
From source file:com.pinterest.teletraan.worker.AutoPromoter.java
License:Apache License
public <E> E getScheduledCheckResult(EnvironBean currEnvBean, PromoteBean promoteBean, List<E> candidates, Function<E, Long> timeSupplier) throws Exception { E ret = null;// w ww. ja v a 2 s . co m //If we have a cron schedule set, foreach candidates, we compute the earilest due // time per schedule for the build. CronExpression cronExpression = new CronExpression(promoteBean.getSchedule()); for (E bean : candidates) { DateTime checkTime = new DateTime(timeSupplier.apply(bean)); if (promoteBean.getDelay() > 0) { checkTime.plusMinutes(promoteBean.getDelay()); } DateTime autoDeployDueDate = new DateTime(cronExpression.getNextValidTimeAfter(checkTime.toDate())); LOG.info("Auto deploy due time is {} for check time {} for Environment {}", autoDeployDueDate.toString(ISODateTimeFormat.dateTime()), checkTime.toString(), currEnvBean.getEnv_name()); if (!autoDeployDueDate.isAfterNow()) { ret = bean; break; } } return ret; }
From source file:com.pinterest.teletraan.worker.AutoPromoter.java
License:Apache License
public Date getScheduledCheckDueTime(long start_date, String cronExpressionString) { Date ret = new Date(0); try {/* www . j a v a 2 s .co m*/ if (!CronExpression.isValidExpression(cronExpressionString)) { LOG.error(String.format("Cron expression %s is not valid. Ignore it.", cronExpressionString)); return ret; } CronExpression cronExpression = new CronExpression(cronExpressionString); Date lastCheckDate = new Date(start_date); ret = cronExpression.getNextValidTimeAfter(lastCheckDate); LOG.info("Get cron {} due time is {} for check time {}", cronExpressionString, new DateTime(ret).toString(ISODateTimeFormat.dateTime()), new DateTime(lastCheckDate).toString(ISODateTimeFormat.dateTime())); return ret; } catch (ParseException e) { LOG.error(String.format("Failed to parse cron expression: %s. Reason: %s", cronExpressionString, e.getMessage())); return ret; } catch (Exception e) { LOG.error(String.format("Failed to validate date. Reason: %s", e.getMessage())); return ret; } }
From source file:com.pungwe.db.io.DBObjectReader.java
License:Apache License
private static DateTime readTimestamp(DataInput input) throws IOException { String dateString = input.readUTF(); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); return fmt.parseDateTime(dateString); }