Example usage for org.apache.commons.lang.time DateFormatUtils ISO_TIME_NO_T_FORMAT

List of usage examples for org.apache.commons.lang.time DateFormatUtils ISO_TIME_NO_T_FORMAT

Introduction

In this page you can find the example usage for org.apache.commons.lang.time DateFormatUtils ISO_TIME_NO_T_FORMAT.

Prototype

FastDateFormat ISO_TIME_NO_T_FORMAT

To view the source code for org.apache.commons.lang.time DateFormatUtils ISO_TIME_NO_T_FORMAT.

Click Source Link

Document

ISO8601-like formatter for time without time zone.

Usage

From source file:de.fhg.iais.commons.time.StopWatch.java

public String stopTime() {
    return DateFormatUtils.formatUTC(stop(), DateFormatUtils.ISO_TIME_NO_T_FORMAT.getPattern());
}

From source file:hr.fer.zemris.vhdllab.view.LogHistoryView.java

private void setupLogAppender(final JTextPane textPane) {
    Logger.getRootLogger().addAppender(new AppenderSkeleton() {
        @Override/*w  ww .j a  va 2s.c  om*/
        protected void append(LoggingEvent event) {
            if (!event.getLevel().equals(Level.INFO)) {
                return;
            }

            StringBuilder sb = new StringBuilder();
            String time = DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(event.timeStamp);
            sb.append(time).append("  ").append(event.getMessage());

            Document document = textPane.getDocument();
            int documentLength = document.getLength();
            try {
                document.insertString(documentLength, sb.toString() + "\n", null);
            } catch (BadLocationException e) {
                throw new IllegalStateException(e);
            }
            // scroll to end of document
            textPane.setCaretPosition(documentLength);
        }

        @Override
        public boolean requiresLayout() {
            return false;
        }

        @Override
        public void close() {
        }
    });
}

From source file:de.fhg.iais.asc.workflow.ASCWorkflow.java

/**
 * Performs the harvesting.//from w w w.j a va2  s .c om
 *
 * @param provider The current {@link AscProvider}.
 * @return An {@link AscProviderIngest} for the new ingest event, non-{@code null}.
 */
private AscProviderIngest harvest(AscProvider provider) {
    // Create an ingest event.
    String eventId = this.config.get(AscConfiguration.INGEST_EVENT, "");
    if (StringUtils.isEmpty(eventId) || "*".equals(eventId)) {
        eventId = String.valueOf(System.currentTimeMillis() / 1000);
    }
    final AscProviderIngest ingestEvent = provider.createIngest(eventId);

    LOG.info("Cleaning up errors from previous runs ...");
    this.config.getASCState().displayMessage("Cleaning up errors from previous runs ...");
    ingestEvent.removeOldErrors(ErrorSip.SECTION_HARVEST);

    LOG.info("Harvesting data ...");
    LOG.info("Start Harvesting");

    this.config.getASCState().displayMessage("Harvesting data ...");

    // Read out proxy information if given.
    String proxyhost = this.config.get(AscConfiguration.OAIPMH_PROXYHOST, "");
    Integer proxyport = null;
    try {
        proxyport = Integer.parseInt(this.config.get(AscConfiguration.OAIPMH_PROXYPORT, "invalid"));
    } catch (NumberFormatException ex) {
        proxyhost = null;
        proxyport = null;
    }

    // Create a harvester.
    final String oaiSource = this.config.get(AscConfiguration.OAI_SOURCE, "");
    final String harvestingformat = this.config.get(AscConfiguration.META_DATA_FORMAT,
            this.config.get(AscConfiguration.FORMAT, ""));
    AbstractHarvester harvester = HarvesterFactory.getInstance().getHarvester(
            this.config.get(AscConfiguration.STRATEGY, ""), oaiSource, harvestingformat, proxyhost, proxyport,
            this.config.get(AscConfiguration.HARVESTING_FROM_DATE, ""),
            this.config.get(AscConfiguration.HARVESTING_UNTIL_DATE, ""), this.config, this.config.getASCState(),
            ingestEvent);

    if (!oaiSource.isEmpty()) {
        // If no OAI source is specified, it does not make sense to harvest (and the harvester will throw NullPointerExceptions).

        StopWatch s = StopWatch.start();
        int n = 0;

        // Create a FileRepositoryWriter.
        File targetDirectory = ingestEvent.getDirectory(AscDirectory.INBOX);
        RepositoryWriter writer = new RepositoryWriter(targetDirectory,
                this.config.get(AscConfiguration.MAX_FILES_EACH, 0), oaiSource, eventId);

        // Harvest.
        final String oaiSets = this.config.get(AscConfiguration.OAI_SET, "");
        if (StringUtils.isEmpty(oaiSets)) {
            n = harvester.retrieveAll(writer);
        } else {
            String[] sets = oaiSets.split(",");

            for (int i = 0; i < sets.length; i++) {
                sets[i] = sets[i].trim();
            }

            for (String set : sets) {
                n = harvester.retrieveSet(set, writer);
            }
        }

        this.config.getASCState().displayMessage(n + " elements in "
                + DateFormatUtils.formatUTC(s.stop(), DateFormatUtils.ISO_TIME_NO_T_FORMAT.getPattern()));
        LOG.info(n + " elements in " + DateFormatUtils.ISO_TIME_NO_T_FORMAT.getPattern());

        s.stop("Time used for harvesting");
    } else {
        LOG.info("Skipping harvesting, because oai_source is empty for the current provider");
    }

    return ingestEvent;
}

From source file:org.apache.hadoop.yarn.client.cli.TopCLI.java

String getHeader(QueueMetrics queueMetrics, NodesInformation nodes) {
    StringBuilder ret = new StringBuilder();
    String queue = "root";
    if (!queues.isEmpty()) {
        queue = StringUtils.join(queues, ",");
    }/*w w w .  j  ava 2  s. co  m*/
    long now = Time.now();
    long uptime = 0L;
    if (rmStartTime != -1) {
        uptime = now - rmStartTime;
    }
    long days = TimeUnit.MILLISECONDS.toDays(uptime);
    long hours = TimeUnit.MILLISECONDS.toHours(uptime)
            - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(uptime));
    long minutes = TimeUnit.MILLISECONDS.toMinutes(uptime)
            - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(uptime));
    String uptimeStr = String.format("%dd, %d:%d", days, hours, minutes);
    String currentTime = DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(now);

    ret.append(CLEAR_LINE);
    ret.append(limitLineLength(String.format("YARN top - %s, up %s, %d active users, queue(s): %s%n",
            currentTime, uptimeStr, queueMetrics.activeUsers, queue), terminalWidth, true));

    ret.append(CLEAR_LINE);
    ret.append(limitLineLength(
            String.format(
                    "NodeManager(s): %d total, %d active, %d unhealthy, %d decommissioned,"
                            + " %d lost, %d rebooted%n",
                    nodes.totalNodes, nodes.runningNodes, nodes.unhealthyNodes, nodes.decommissionedNodes,
                    nodes.lostNodes, nodes.rebootedNodes),
            terminalWidth, true));

    ret.append(CLEAR_LINE);
    ret.append(limitLineLength(String.format(
            "Queue(s) Applications: %d running, %d submitted, %d pending,"
                    + " %d completed, %d killed, %d failed%n",
            queueMetrics.appsRunning, queueMetrics.appsSubmitted, queueMetrics.appsPending,
            queueMetrics.appsCompleted, queueMetrics.appsKilled, queueMetrics.appsFailed), terminalWidth,
            true));

    ret.append(CLEAR_LINE);
    ret.append(limitLineLength(
            String.format("Queue(s) Mem(GB): %d available," + " %d allocated, %d pending, %d reserved%n",
                    queueMetrics.availableMemoryGB, queueMetrics.allocatedMemoryGB,
                    queueMetrics.pendingMemoryGB, queueMetrics.reservedMemoryGB),
            terminalWidth, true));

    ret.append(CLEAR_LINE);
    ret.append(limitLineLength(
            String.format("Queue(s) VCores: %d available," + " %d allocated, %d pending, %d reserved%n",
                    queueMetrics.availableVCores, queueMetrics.allocatedVCores, queueMetrics.pendingVCores,
                    queueMetrics.reservedVCores),
            terminalWidth, true));

    ret.append(CLEAR_LINE);
    ret.append(limitLineLength(String.format("Queue(s) Containers: %d allocated, %d pending, %d reserved%n",
            queueMetrics.allocatedContainers, queueMetrics.pendingContainers, queueMetrics.reservedContainers),
            terminalWidth, true));
    return ret.toString();
}

From source file:org.marketcetera.photon.internal.marketdata.ui.MarketDepthView.java

private IObservableMap createTimeMap(ObservableListContentProvider bids) {
    // a custom map that formats the time
    return new EObjectObservableMap(bids.getKnownElements(), MDPackage.Literals.MD_QUOTE__TIME) {
        @Override//from  w ww .  jav  a2  s.  c  om
        protected Object doGet(Object key) {
            long l = (Long) super.doGet(key);
            return DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(l);
        }
    };
}

From source file:org.openmrs.module.emrmonitor.metric.JavaRuntimeMetricProducer.java

/**
 * @return a list of produced metrics/*w  ww. ja v  a  2s  . c  om*/
 */
@Override
public Map<String, String> produceMetrics() {

    Map<String, String> metrics = new LinkedHashMap<String, String>();

    // Memory
    Runtime runtime = Runtime.getRuntime();
    metrics.put("memory.total", FormatUtil.formatBytes(runtime.totalMemory()));
    metrics.put("memory.total.bytes", Long.toString(runtime.totalMemory()));
    metrics.put("memory.free", FormatUtil.formatBytes(runtime.freeMemory()));
    metrics.put("memory.free.bytes", Long.toString(runtime.freeMemory()));
    metrics.put("memory.maximum", FormatUtil.formatBytes(runtime.maxMemory()));
    metrics.put("memory.maximum.bytes", Long.toString(runtime.maxMemory()));

    // Date/time
    Calendar cal = Calendar.getInstance();
    metrics.put("datetime.display", DateFormat.getDateTimeInstance().format(cal.getTime()));
    metrics.put("datetime.date", DateFormatUtils.ISO_DATE_FORMAT.format(cal));
    metrics.put("datetime.time", DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(cal));
    metrics.put("datetime.timezone", cal.getTimeZone().getDisplayName());

    // Java
    Properties sp = System.getProperties();
    metrics.put("version", sp.getProperty("java.version"));
    metrics.put("vendor", sp.getProperty("java.vendor"));
    metrics.put("jvmVersion", sp.getProperty("java.vm.version"));
    metrics.put("jvmVendor", sp.getProperty("java.vm.vendor"));
    metrics.put("runtimeName", sp.getProperty("java.runtime.name"));
    metrics.put("runtimeVersion", sp.getProperty("java.runtime.version"));
    metrics.put("user.name", sp.getProperty("user.name"));
    metrics.put("user.language", sp.getProperty("user.language"));
    metrics.put("user.timezone", sp.getProperty("user.timezone"));
    metrics.put("user.directory", sp.getProperty("user.dir"));
    metrics.put("encoding", sp.getProperty("sun.jnu.encoding"));
    metrics.put("tempDirectory", sp.getProperty("java.io.tmpdir"));

    return metrics;
}