Example usage for org.joda.time.format ISODateTimeFormat dateTimeNoMillis

List of usage examples for org.joda.time.format ISODateTimeFormat dateTimeNoMillis

Introduction

In this page you can find the example usage for org.joda.time.format ISODateTimeFormat dateTimeNoMillis.

Prototype

public static DateTimeFormatter dateTimeNoMillis() 

Source Link

Document

Returns a formatter that combines a full date and time without millis, separated by a 'T' (yyyy-MM-dd'T'HH:mm:ssZZ).

Usage

From source file:VMwareInventory.java

public void register(String url) throws Exception {
    Extension extension = new Extension();
    Description description = new Description();
    ExtensionServerInfo serverInfo = new ExtensionServerInfo();
    DateTimeFormatter parser2 = ISODateTimeFormat.dateTimeNoMillis();
    Calendar lastHeartbeatTime = (Calendar) Calendar.getInstance(TimeZone.getTimeZone("GMT")).clone();
    lastHeartbeatTime.setTime(parser2.parseDateTime("2012-12-21T00:00:00Z").toDate());
    extension.setKey(this.EXT_KEY);
    extension.setCompany(this.EXT_COMPANY);
    extension.setType(this.EXT_TYPE);
    extension.setVersion(this.EXT_VERSION);
    extension.setLastHeartbeatTime(lastHeartbeatTime);
    description.setLabel(this.EXT_LABEL);
    description.setSummary(this.EXT_LABEL);
    extension.setDescription(description);
    serverInfo.setUrl(url);//from   ww  w  .  ja  v  a  2 s  . c  o  m
    serverInfo.setDescription(description);
    serverInfo.setCompany(this.EXT_COMPANY);
    serverInfo.setType(this.EXT_TYPE);
    serverInfo.setAdminEmail(this.EXT_ADMIN_EMAIL);
    this.getExtensionManager().unregisterExtension(this.EXT_KEY);
    this.getExtensionManager().registerExtension(extension);
}

From source file:VMwareInventory.java

public HashMap<String, Object> findByUuidWithReadings(String uuid, String startIso8601, String endIso8601)
        throws Exception {
    logger.fine("Entering VMwareInventory.findByUuidWithReadings()");
    VirtualMachine[] vms = new VirtualMachine[1];
    VirtualMachine vm = (VirtualMachine) this.si.getSearchIndex().findByUuid(null, uuid, true, false);
    DateTimeFormatter parser2 = ISODateTimeFormat.dateTimeNoMillis();
    Calendar startTime = (Calendar) Calendar.getInstance(TimeZone.getTimeZone("GMT")).clone();
    Calendar endTime = (Calendar) Calendar.getInstance(TimeZone.getTimeZone("GMT")).clone();
    startTime.setTime(parser2.parseDateTime(startIso8601).toDate());
    endTime.setTime(parser2.parseDateTime(endIso8601).toDate());
    vms[0] = vm;/*from w  ww  . j  a  v a 2 s  . co  m*/
    gatherProperties(vms);
    List<VirtualMachine> vms_list = new ArrayList<VirtualMachine>(Arrays.asList(vms));
    readings(vms_list, startTime, endTime);
    logger.fine("Exiting VMwareInventory.findByUuidWithReadings()");
    return vmMap.get(vm.getMOR().get_value().toString());
}

From source file:VMwareInventory.java

/**
 * readings//from w  w w. ja v a2s. co m
 *
 * gather all VMs and readings.  Populates this.vmMap and this.hostMap
 *
 * @param  startIso8601 String
 * @param  endIso8601 String
 */
public void readings(String startIso8601, String endIso8601) throws Exception {
    logger.fine("Entering VMwareInventory.readings(String startIso8601, String endIso8601)");
    DateTimeFormatter parser2 = ISODateTimeFormat.dateTimeNoMillis();
    logger.info(startIso8601 + " " + endIso8601);
    Calendar startTime = (Calendar) Calendar.getInstance(TimeZone.getTimeZone("GMT")).clone();
    Calendar endTime = (Calendar) Calendar.getInstance(TimeZone.getTimeZone("GMT")).clone();
    startTime.setTime(parser2.parseDateTime(startIso8601).toDate());
    endTime.setTime(parser2.parseDateTime(endIso8601).toDate());
    readings(startTime, endTime);
    logger.fine("Exiting VMwareInventory.readings(String startIso8601, String endIso8601)");
}

From source file:VMwareInventory.java

/**
 * readings/*from ww w  .  j av a  2  s. c om*/
 *
 * gather properties for VMs in requested List and readings.  Populates this.vmMap and this.hostMap
 *
 * @param  vms List<VirtualMachine> 
 * @param  startTime Calendar
 * @param  endTime Calendar
 */
public void readings(List<VirtualMachine> vms, Calendar startTime, Calendar endTime) throws Exception {
    logger.fine(
            "Entering VMwareInventory.readings(List<VirtualMachine> vms, Calendar startTime, Calendar endTime)");
    String[] counterNames = { "cpu.usage.average", "cpu.usagemhz.average", "mem.consumed.average",
            "virtualDisk.read.average", "virtualDisk.write.average", "net.received.average",
            "net.transmitted.average" };
    gatherCounters();
    PerfMetricId cpu_usage = new PerfMetricId();
    cpu_usage.setCounterId(this.counterMap.get("cpu.usage.average"));
    cpu_usage.setInstance("");

    PerfMetricId cpu_usagemhz = new PerfMetricId();
    cpu_usagemhz.setCounterId(this.counterMap.get("cpu.usagemhz.average"));
    cpu_usagemhz.setInstance("");

    PerfMetricId mem = new PerfMetricId();
    mem.setCounterId(this.counterMap.get("mem.consumed.average"));
    mem.setInstance("");

    PerfMetricId vdisk_read = new PerfMetricId();
    vdisk_read.setCounterId(this.counterMap.get("virtualDisk.read.average"));
    vdisk_read.setInstance("*");

    PerfMetricId vdisk_write = new PerfMetricId();
    vdisk_write.setCounterId(this.counterMap.get("virtualDisk.write.average"));
    vdisk_write.setInstance("*");

    PerfMetricId net_recv = new PerfMetricId();
    net_recv.setCounterId(this.counterMap.get("net.received.average"));
    net_recv.setInstance("*");

    PerfMetricId net_trans = new PerfMetricId();
    net_trans.setCounterId(this.counterMap.get("net.transmitted.average"));
    net_trans.setInstance("*");

    List<PerfQuerySpec> qSpecList = new ArrayList<PerfQuerySpec>();
    Iterator it = vms.iterator();
    while (it.hasNext()) {
        PerfQuerySpec qSpec = new PerfQuerySpec();
        VirtualMachine vm = (VirtualMachine) it.next();
        qSpec.setEntity(vm.getMOR());
        qSpec.setFormat("normal");
        qSpec.setIntervalId(300);
        qSpec.setMetricId(new PerfMetricId[] { cpu_usage, cpu_usagemhz, mem, vdisk_read, vdisk_write,
                vdisk_write, net_trans, net_recv });
        qSpec.setStartTime(startTime);
        qSpec.setEndTime(endTime);
        qSpecList.add(qSpec);
    }

    PerformanceManager pm = getPerformanceManager();
    PerfQuerySpec[] pqsArray = qSpecList.toArray(new PerfQuerySpec[qSpecList.size()]);
    logger.info("Start PerformanceManager.queryPerf");
    PerfEntityMetricBase[] pembs = pm.queryPerf(pqsArray);
    logger.info("Finished PerformanceManager.queryPerf");
    logger.info("Start gathering of valid timestamps");
    DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
    String timestamp = fmt.withZone(DateTimeZone.UTC).print(endTime.getTimeInMillis());
    this.tsSet.add(timestamp);
    for (int i = 0; pembs != null && i < pembs.length; i++) {
        if (pembs[i] instanceof PerfEntityMetric) {
            parseValidTimestamps((PerfEntityMetric) pembs[i]);
        }

    }
    // Prepopulate with all timestamps
    String[] ts = this.tsSet.toArray(new String[0]);
    for (String moref : this.vmMap.keySet()) {
        HashMap<String, HashMap<String, Long>> metrics = new HashMap<String, HashMap<String, Long>>();
        for (int i = 0; ts != null && i < ts.length; i++) {
            metrics.put(ts[i], new HashMap<String, Long>());
        }
        this.vmMap.get(moref).put("stats", metrics);
    }
    logger.info("Finished gathering of valid timestamps");
    logger.info("Start parsing metrics");
    for (int i = 0; pembs != null && i < pembs.length; i++) {
        //DEBUG - printPerfMetric(pembs[i]);
        if (pembs[i] instanceof PerfEntityMetric) {
            String vm_mor = pembs[i].getEntity().get_value();
            HashMap<String, HashMap<String, Long>> metrics = parsePerfMetricForVM(vm_mor,
                    (PerfEntityMetric) pembs[i]);
            this.vmMap.get(vm_mor).put("stats", metrics);
            // DEBUG - printMachineReading(vm_mor,metrics);
        }
    }
    logger.info("Finished parsing metrics");
    logger.fine("Exiting VMwareInventory.readings(String startIso8601, String endIso8601)");
}

From source file:VMwareInventory.java

private void parseValidTimestamps(PerfEntityMetric pem) {
    logger.fine("Entering VMwareInventory.readings(String startIso8601, String endIso8601)");
    PerfSampleInfo[] infos = pem.getSampleInfo();
    for (int i = 0; infos != null && i < infos.length; i++) {
        DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
        String timestamp = fmt.withZone(DateTimeZone.UTC).print(infos[i].getTimestamp().getTimeInMillis());
        this.tsSet.add(timestamp);
        logger.finer("parseValidTimestmaps() found " + timestamp);
    }//w w w. j a va  2s .  c  o  m
    logger.fine(
            "Exiting VMwareInventory.readings(List<VirtualMachine> vms, Calendar startTime, Calendar endTime)");

}

From source file:VMwareInventory.java

private HashMap<String, HashMap<String, Long>> parsePerfMetricForVM(String vm_mor, PerfEntityMetric pem) {
    logger.fine("Entering VMwareInventory.parsePerfMetricForVM(String vm_mor, PerfEntityMetric pem)");
    PerfMetricSeries[] vals = pem.getValue();
    PerfSampleInfo[] infos = pem.getSampleInfo();
    HashMap<String, Object> vm_hash = this.vmMap.get(vm_mor);
    @SuppressWarnings("unchecked")
    HashMap<String, HashMap<String, Long>> metrics = (HashMap<String, HashMap<String, Long>>) vm_hash
            .get("stats");
    // Prepopulate with all timestamps
    String[] ts = this.tsSet.toArray(new String[0]);
    for (int i = 0; ts != null && i < ts.length; i++) {
        metrics.put(ts[i], new HashMap<String, Long>());
    }//from   www  . j  ava2 s .co  m
    // Fill in metrics gathered
    for (int i = 0; infos != null && i < infos.length; i++) {
        DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
        String timestamp = fmt.withZone(DateTimeZone.UTC).print(infos[i].getTimestamp().getTimeInMillis());
        for (int j = 0; vals != null && j < vals.length; ++j) {
            String counterName = this.counterIdMap.get(vals[j].getId().getCounterId());
            String instanceName = vals[j].getId().getInstance();
            String metricName = counterName;
            if (instanceName.length() > 0) {
                metricName = counterName + "." + instanceName;
            }
            if (vals[j] instanceof PerfMetricIntSeries) {
                PerfMetricIntSeries val = (PerfMetricIntSeries) vals[j];
                long[] longs = val.getValue();
                long value = longs[i];
                metrics.get(timestamp).put(metricName, value);
                logger.finer("parsePerfMetricForVM adding " + timestamp + " " + metricName + " " + value);
            }
        }
    }
    logger.fine("Exiting VMwareInventory.parsePerfMetricForVM(String vm_mor, PerfEntityMetric pem)");
    return (metrics);
}

From source file:be.dnsbelgium.rdap.jackson.DateTimeSerializer.java

License:Apache License

@Override
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    if (value == null) {
        jgen.writeNull();//  ww w . j  a  v  a2s. com
    } else {
        jgen.writeString(value.toString(ISODateTimeFormat.dateTimeNoMillis()));
    }
}

From source file:be.fedict.eid.applet.service.signer.odf.OpenOfficeSignatureFacet.java

License:Open Source License

public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId,
        List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    LOG.debug("pre sign");

    Element dateElement = document.createElementNS("", "dc:date");
    dateElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:dc", "http://purl.org/dc/elements/1.1/");
    DateTime dateTime = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
    String now = fmt.print(dateTime);
    now = now.substring(0, now.indexOf("Z"));
    LOG.debug("now: " + now);
    dateElement.setTextContent(now);// w  w  w .j a  va 2s .  c om

    String signaturePropertyId = "sign-prop-" + UUID.randomUUID().toString();
    List<XMLStructure> signaturePropertyContent = new LinkedList<XMLStructure>();
    signaturePropertyContent.add(new DOMStructure(dateElement));
    SignatureProperty signatureProperty = signatureFactory.newSignatureProperty(signaturePropertyContent,
            "#" + signatureId, signaturePropertyId);

    List<XMLStructure> objectContent = new LinkedList<XMLStructure>();
    List<SignatureProperty> signaturePropertiesContent = new LinkedList<SignatureProperty>();
    signaturePropertiesContent.add(signatureProperty);
    SignatureProperties signatureProperties = signatureFactory
            .newSignatureProperties(signaturePropertiesContent, null);
    objectContent.add(signatureProperties);

    objects.add(signatureFactory.newXMLObject(objectContent, null, null, null));

    DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null);
    Reference reference = signatureFactory.newReference("#" + signaturePropertyId, digestMethod);
    references.add(reference);
}

From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureFacet.java

License:Open Source License

private void addSignatureTime(XMLSignatureFactory signatureFactory, Document document, String signatureId,
        List<XMLStructure> objectContent) {
    /*/*  ww w . j av a  2 s . com*/
     * SignatureTime
     */
    Element signatureTimeElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:SignatureTime");
    signatureTimeElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:mdssi", OOXML_DIGSIG_NS);
    Element formatElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:Format");
    formatElement.setTextContent("YYYY-MM-DDThh:mm:ssTZD");
    signatureTimeElement.appendChild(formatElement);
    Element valueElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:Value");
    Date now = this.clock.getTime();
    DateTime dateTime = new DateTime(now.getTime(), DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
    String nowStr = fmt.print(dateTime);
    LOG.debug("now: " + nowStr);
    valueElement.setTextContent(nowStr);
    signatureTimeElement.appendChild(valueElement);

    List<XMLStructure> signatureTimeContent = new LinkedList<XMLStructure>();
    signatureTimeContent.add(new DOMStructure(signatureTimeElement));
    SignatureProperty signatureTimeSignatureProperty = signatureFactory
            .newSignatureProperty(signatureTimeContent, "#" + signatureId, "idSignatureTime");
    List<SignatureProperty> signaturePropertyContent = new LinkedList<SignatureProperty>();
    signaturePropertyContent.add(signatureTimeSignatureProperty);
    SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertyContent,
            "id-signature-time-" + UUID.randomUUID().toString());
    objectContent.add(signatureProperties);
}

From source file:ca.ualberta.physics.cssdp.util.JSONDateTimeNoMillisSerializer.java

License:Apache License

@Override
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    jgen.writeString(ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(value));
}