Example usage for javax.xml.datatype XMLGregorianCalendar toGregorianCalendar

List of usage examples for javax.xml.datatype XMLGregorianCalendar toGregorianCalendar

Introduction

In this page you can find the example usage for javax.xml.datatype XMLGregorianCalendar toGregorianCalendar.

Prototype

public abstract GregorianCalendar toGregorianCalendar();

Source Link

Document

Convert this XMLGregorianCalendar to a GregorianCalendar .

Usage

From source file:org.researchgraph.crosswalk.CrosswalkRG.java

private boolean processDataset(final Dataset dataset, final Graph graph, boolean deleted) {
    ++existingRecords;//from w  w w .j  av  a2  s.c o  m

    if (verbose)
        System.out.println("Processing Dataset");

    String key = dataset.getKey();
    if (StringUtils.isEmpty(key)) {
        return false;
    }

    if (verbose)
        System.out.println("Key: " + key);

    String source = dataset.getSource();
    if (StringUtils.isEmpty(source))
        source = this.source;

    GraphNode node = GraphNode.builder().withKey(new GraphKey(source, key)).withNodeSource(source)
            .withNodeType(GraphUtils.TYPE_DATASET).withLabel(this.source).withLabel(GraphUtils.TYPE_DATASET)
            .build();

    if (deleted) {
        node.setDeleted(true);
        graph.addNode(node);

        ++deletedRecords;

        return true;
    }

    String localId = dataset.getLocalId();
    if (!StringUtils.isEmpty(localId))
        node.setProperty(GraphUtils.PROPERTY_LOCAL_ID, localId);

    XMLGregorianCalendar lastUpdated = dataset.getLastUpdated();
    if (null != lastUpdated) {
        String lastUpdatedString = formatter.format(lastUpdated.toGregorianCalendar().getTime());
        if (!StringUtils.isEmpty(lastUpdatedString))
            node.setProperty(GraphUtils.PROPERTY_LAST_UPDATED, lastUpdatedString);
    }

    String url = GraphUtils.extractFormalizedUrl(dataset.getUrl());
    if (!StringUtils.isEmpty(url))
        node.setProperty(GraphUtils.PROPERTY_URL, url);

    String title = dataset.getTitle();
    if (!StringUtils.isEmpty(title))
        node.setProperty(GraphUtils.PROPERTY_TITLE, title);

    String doi = GraphUtils.extractDoi(dataset.getDoi());
    if (!StringUtils.isEmpty(doi))
        node.setProperty(GraphUtils.PROPERTY_DOI, doi);

    XMLGregorianCalendar publicationYear = dataset.getPublicationYear();
    if (null != publicationYear && publicationYear.getYear() > 0)
        node.setProperty(GraphUtils.PROPERTY_PUBLICATION_YEAR, publicationYear.getYear());

    String license = GraphUtils.extractFormalizedUrl(dataset.getLicense());
    if (!StringUtils.isEmpty(license))
        node.setProperty(GraphUtils.PROPERTY_LICENSE, license);

    BigDecimal megabyte = dataset.getMegabyte();
    if (null != megabyte)
        node.setProperty(GraphUtils.PROPERTY_MEGABYTE, megabyte.toString());

    graph.addNode(node);

    return true;
}

From source file:org.researchgraph.crosswalk.CrosswalkRG.java

private boolean processPublication(final Publication publication, final Graph graph, boolean deleted) {
    ++existingRecords;//from w ww  . j a  v  a 2 s.c  om

    if (verbose)
        System.out.println("Processing Publication");

    String key = publication.getKey();
    if (StringUtils.isEmpty(key)) {
        return false;
    }

    if (verbose)
        System.out.println("Key: " + key);

    String source = publication.getSource();
    if (StringUtils.isEmpty(source))
        source = this.source;

    GraphNode node = GraphNode.builder().withKey(new GraphKey(source, key)).withNodeSource(source)
            .withNodeType(GraphUtils.TYPE_PUBLICATION).withLabel(this.source)
            .withLabel(GraphUtils.TYPE_PUBLICATION).build();

    if (deleted) {
        node.setDeleted(true);
        graph.addNode(node);

        ++deletedRecords;

        return true;
    }

    String localId = publication.getLocalId();
    if (!StringUtils.isEmpty(localId))
        node.setProperty(GraphUtils.PROPERTY_LOCAL_ID, localId);

    XMLGregorianCalendar lastUpdated = publication.getLastUpdated();
    if (null != lastUpdated) {
        String lastUpdatedString = formatter.format(lastUpdated.toGregorianCalendar().getTime());
        if (!StringUtils.isEmpty(lastUpdatedString))
            node.setProperty(GraphUtils.PROPERTY_LAST_UPDATED, lastUpdatedString);
    }

    String url = GraphUtils.extractFormalizedUrl(publication.getUrl());
    if (!StringUtils.isEmpty(url))
        node.setProperty(GraphUtils.PROPERTY_URL, url);

    String title = publication.getTitle();
    if (!StringUtils.isEmpty(title))
        node.setProperty(GraphUtils.PROPERTY_TITLE, title);

    String authorsList = publication.getAuthorsList();
    if (!StringUtils.isEmpty(authorsList))
        node.setProperty(GraphUtils.PROPERTY_AUTHORS, authorsList);

    String doi = GraphUtils.extractDoi(publication.getDoi());
    if (!StringUtils.isEmpty(doi))
        node.setProperty(GraphUtils.PROPERTY_DOI, doi);

    XMLGregorianCalendar publicationYear = publication.getPublicationYear();
    if (null != publicationYear && publicationYear.getYear() > 0)
        node.setProperty(GraphUtils.PROPERTY_PUBLICATION_YEAR, publicationYear.getYear());

    String scopusEid = GraphUtils.extractScopusEID(publication.getScopusEid());
    if (!StringUtils.isEmpty(scopusEid))
        node.setProperty(GraphUtils.PROPERTY_SCOPUS_EID, scopusEid);

    graph.addNode(node);

    return true;
}

From source file:org.socraticgrid.util.CommonUtil.java

public static List<String> getDateTime(XMLGregorianCalendar xgc) {
    Date d = xgc.toGregorianCalendar().getTime();
    List<String> dateTime = new ArrayList(2);
    Format formatter = new SimpleDateFormat("yyyy-MM-dd");
    String msgDate = formatter.format(d);
    dateTime.add(msgDate);//from w w  w  . ja  v a  2  s  . co  m
    formatter = new SimpleDateFormat("hh:mm");
    String msgTime = formatter.format(d);
    dateTime.add(msgTime);
    return dateTime;
}

From source file:org.yawlfoundation.yawl.util.StringUtil.java

public static long xmlDateToLong(String s) {
    if (s == null)
        return -1;
    try {/*from   w  ww  .jav  a 2  s . co m*/
        XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(s);
        return cal.toGregorianCalendar().getTimeInMillis();
    } catch (DatatypeConfigurationException dce) {
        return -1;
    }
}

From source file:pl.umk.mat.zawodyweb.www.zip.ZipFile.java

static Date convert(XMLGregorianCalendar xmlDate) {
    try {/*from  w w w.  j a  v  a 2 s . co m*/
        return xmlDate.toGregorianCalendar().getTime();
    } catch (Exception e) {
        return null;
    }
}

From source file:tds.student.services.impl.RtsServiceImpl.java

private static String formatDateString(final XMLGregorianCalendar date) {
    if (date == null)
        return "";

    SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    return sdf.format(date.toGregorianCalendar().getTime());
}