当前位置: 首页>>代码示例>>Java>>正文


Java DatatypeConverter.parseDateTime方法代码示例

本文整理汇总了Java中javax.xml.bind.DatatypeConverter.parseDateTime方法的典型用法代码示例。如果您正苦于以下问题:Java DatatypeConverter.parseDateTime方法的具体用法?Java DatatypeConverter.parseDateTime怎么用?Java DatatypeConverter.parseDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.DatatypeConverter的用法示例。


在下文中一共展示了DatatypeConverter.parseDateTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyAssertionExpirationDate

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Verify that the NotOnOrAfter attribute in any bearer
 * <SubjectConfirmationData> has not passed, subject to allowable clock skew
 * between the providers
 * 
 * @throws AssertionValidationException
 */
void verifyAssertionExpirationDate(Node nodeAssertion,
        Node nodeConfirmationData) throws AssertionValidationException {

    Calendar expirationDate = DatatypeConverter.parseDateTime(XMLConverter
            .getStringAttValue(nodeConfirmationData,
                    SamlXmlTags.ATTRIBUTE_NOT_ON_OR_AFTER));
    if (now.equals(expirationDate) || now.after(expirationDate)) {
        String assertionId = XMLConverter.getStringAttValue(nodeAssertion,
                SamlXmlTags.ATTRIBUTE_ID);
        AssertionValidationException exception = new AssertionValidationException(
                String.format("Assertion (id=%s) expired", assertionId),
                AssertionValidationException.ReasonEnum.ASSERTION_EXPIRED,
                new String[] { assertionId });
        throw exception;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:AssertionContentVerifier.java

示例2: parseDateTime

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static java.util.Calendar parseDateTime(String lexicalXSDDateTime) {
    return DatatypeConverter.parseDateTime(lexicalXSDDateTime.trim());
}
 
开发者ID:AlnaSoftware,项目名称:eSaskaita,代码行数:4,代码来源:CustomDatatypeConverter.java

示例3: readExpirationDateFromXml

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private Calendar readExpirationDateFromXml(Node nodeConfirmationData) {
    return DatatypeConverter.parseDateTime(XMLConverter.getStringAttValue(
            nodeConfirmationData, SamlXmlTags.ATTRIBUTE_NOT_ON_OR_AFTER));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:5,代码来源:AssertionContentVerifierTest.java

示例4: createIndex

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@SneakyThrows
public void createIndex(String sipId, int xmlVersion, String arclibXml) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    Document xml;
    try {
        xml = factory.newDocumentBuilder().parse(new ByteArrayInputStream(arclibXml.getBytes()));
    } catch (ParserConfigurationException | SAXException | IOException e) {
        log.error("Error during parsing of XML document");
        throw e;
    }
    XPath xpath = getXpathWithNamespaceContext();
    ArclibXmlDocument solrArclibXmlDocument = new ArclibXmlDocument();

    SolrInputDocument doc = new SolrInputDocument();
    for (IndexFieldConfig conf : getFieldsConfig()) {
        NodeList fields = (NodeList) xpath.evaluate(conf.getXpath(), xml, XPathConstants.NODESET);

        for (int i = 0; i < fields.getLength(); i++) {
            try {
                switch (conf.getFieldType()) {
                    case DATETIME:
                        Calendar parsedDate = DatatypeConverter.parseDateTime(fields.item(i).getTextContent());
                        String parsedDateTimeString = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(parsedDate.toInstant().atZone(ZoneId.systemDefault()));
                        solrArclibXmlDocument.addField(conf.getFieldName(), parsedDateTimeString);
                        break;
                    case DATE:
                        parsedDate = DatatypeConverter.parseDate(fields.item(i).getTextContent());
                        String parsedDateString = DateTimeFormatter.ISO_LOCAL_DATE.format(parsedDate.toInstant().atZone(ZoneId.systemDefault()));
                        solrArclibXmlDocument.addField(conf.getFieldName(), parsedDateString);
                        break;
                    case TIME:
                        ZonedDateTime time = DatatypeConverter.parseTime(fields.item(i).getTextContent()).toInstant().atZone(ZoneId.systemDefault());
                        long parsedTime = time.getHour() * 60 * 60 * 1000 + time.getMinute() * 60 * 1000 + time.getSecond() * 1000;
                        solrArclibXmlDocument.addField(conf.getFieldName(), parsedTime);
                        break;
                    default:
                        if (conf.isFullText()) {
                            solrArclibXmlDocument.addField(conf.getFieldName(), nodeToString(fields.item(i)));
                        } else {
                            solrArclibXmlDocument.addField(conf.getFieldName(), fields.item(i).getTextContent());
                        }
                }
            } catch (IllegalArgumentException | NullPointerException parsingEx) {
                String msg = String.format("Could not parse %s as %s", fields.item(i).getTextContent(), conf.getFieldType());
                log.error(msg);
                throw new BadArgument(msg);
            }
        }

    }
    solrArclibXmlDocument.setId(sipId + "_" + xmlVersion);
    solrArclibXmlDocument.setDocument(arclibXml);
    try {
        arclibXmlRepository.save(solrArclibXmlDocument);
    } catch (UncategorizedSolrException ex) {
        log.error(ex.getMessage());
        throw ex;
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:61,代码来源:SolrStore.java


注:本文中的javax.xml.bind.DatatypeConverter.parseDateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。