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


Java DatatypeFactory.newInstance方法代码示例

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


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

示例1: convert2XMLCalendar

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public static XMLGregorianCalendar convert2XMLCalendar(Calendar calendar) {
    try {
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        return dtf.newXMLGregorianCalendar(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.DAY_OF_MONTH),
                calendar.get(Calendar.HOUR),
                calendar.get(Calendar.MINUTE),
                calendar.get(Calendar.SECOND),
                calendar.get(Calendar.MILLISECOND),
                calendar.get(Calendar.ZONE_OFFSET) / (1000 * 60));

    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:autumnkuang,项目名称:nenlvse1.0,代码行数:19,代码来源:DateUtil.java

示例2: newXMLGregorianCalendarSystemTime

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * 
 * @return An object of type XMLGregorianCalendar containing the current
 *         system time and date
 * @throws DatatypeConfigurationException
 *             If the instantiation of the DatatypeFactory fails
 */
public static XMLGregorianCalendar newXMLGregorianCalendarSystemTime()
        throws DatatypeConfigurationException {
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    XMLGregorianCalendar now = datatypeFactory
            .newXMLGregorianCalendar(gregorianCalendar);
    return now;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:GregorianCalendars.java

示例3: preparePeriod

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
private Period preparePeriod(long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {

    Period period = new Period();

    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gc = new GregorianCalendar();

    period.setStartDate(BigInteger.valueOf(periodStartTime));
    gc.setTimeInMillis(periodStartTime);
    period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    period.setEndDate(BigInteger.valueOf(periodEndTime));
    gc.setTimeInMillis(periodEndTime);
    period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    return period;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:SupplierShareResultAssembler.java

示例4: main

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "0001-01-01T00:00:00.0000000-05:00";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "Expected: 0001-01-01T00:00:00.0000000-05:00");
        System.out.println( "Actual:" + cal.toString() );
        System.out.println( "toXMLFormat:" + cal.toXMLFormat() );
        String test = cal.toString();
        if (test.indexOf("E-7") > -1) {
            throw new RuntimeException("Expected: 0001-01-01T00:00:00.0000000-05:00");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:CalendarDuration1097Test.java

示例5: getDatatypeFactory

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public static DatatypeFactory getDatatypeFactory() {
    ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
        public ClassLoader run() {
            return Thread.currentThread().getContextClassLoader();
        }
    });
    DatatypeFactory df = DF_CACHE.get(tccl);
    if (df == null) {
        synchronized (DatatypeConverterImpl.class) {
            df = DF_CACHE.get(tccl);
            if (df == null) { // to prevent multiple initialization
                try {
                    df = DatatypeFactory.newInstance();
                } catch (DatatypeConfigurationException e) {
                    throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e);
                }
                DF_CACHE.put(tccl, df);
            }
        }
    }
    return df;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:23,代码来源:DatatypeConverterImpl.java

示例6: getDataTypeFactory

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
/**
 * Gets a static instance of a JAXP DatatypeFactory.
 * 
 * @return the factory or null if the factory could not be created
 */
public static DatatypeFactory getDataTypeFactory() {
    if (dataTypeFactory == null) {
        try {
            dataTypeFactory = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            // do nothing
        }
    }

    return dataTypeFactory;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:XMLHelper.java

示例7: applyOutages

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public AppliedOutages applyOutages(Calendar calendar, boolean assumeConnected) {
	appliedOutages = ModelParser.applyOutages(calendar, rdfModel, assumeConnected);
	GregorianCalendar gregorianCalendar = new GregorianCalendar();
	gregorianCalendar.setTime(appliedOutages.getEffectiveEnd().getTime());
	try {
		DatatypeFactory factory = DatatypeFactory.newInstance();
		endDate = factory.newXMLGregorianCalendar(gregorianCalendar);
		Duration oneSecond = factory.newDuration("PT1S");
		endDate.add(oneSecond);
	} catch (DatatypeConfigurationException e) {
		// do nothing
	}
	return appliedOutages;
}
 
开发者ID:OmniPrise,项目名称:cim-processor,代码行数:15,代码来源:ModelParser.java

示例8: jaxpFactories

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@DataProvider(name = "jaxpFactories")
public Object[][] jaxpFactories() throws Exception {
    return new Object[][] {
            { DocumentBuilderFactory.newInstance(), (Produce)factory -> ((DocumentBuilderFactory)factory).newDocumentBuilder() },
            { SAXParserFactory.newInstance(), (Produce)factory -> ((SAXParserFactory)factory).newSAXParser() },
            { SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI), (Produce)factory -> ((SchemaFactory)factory).newSchema() },
            { TransformerFactory.newInstance(), (Produce)factory -> ((TransformerFactory)factory).newTransformer() },
            { XMLEventFactory.newInstance(), (Produce)factory -> ((XMLEventFactory)factory).createStartDocument() },
            { XMLInputFactory.newInstance(), (Produce)factory -> ((XMLInputFactory)factory).createXMLEventReader(new StringReader("")) },
            { XMLOutputFactory.newInstance(), (Produce)factory -> ((XMLOutputFactory)factory).createXMLEventWriter(new StringWriter()) },
            { XPathFactory.newInstance(), (Produce)factory -> ((XPathFactory)factory).newXPath() },
            { DatatypeFactory.newInstance(), (Produce)factory -> ((DatatypeFactory)factory).newXMLGregorianCalendar() }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DefaultFactoryWrapperTest.java

示例9: TimeAwareDemoGenerator

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
public TimeAwareDemoGenerator(ProcessEngine engine, ProcessApplicationReference originalProcessApplicationReference,
    ProcessApplicationReference simulatingProcessApplicationReference) {
  this.engine = engine;
  this.originalProcessApplication = originalProcessApplicationReference;
  this.simulatingProcessApplication = simulatingProcessApplicationReference;
  try {
    datatypeFactory = DatatypeFactory.newInstance();
  } catch (DatatypeConfigurationException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:camunda-consulting,项目名称:camunda-util-demo-data-generator,代码行数:12,代码来源:TimeAwareDemoGenerator.java

示例10: convertAspectPropertyValue

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
private String convertAspectPropertyValue(Object value)
{
    if (value instanceof Date)
    {
        GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
        cal.setTime((Date) value);
        value = cal;
    }

    if (value instanceof GregorianCalendar)
    {
        DatatypeFactory df;
        try
        {
            df = DatatypeFactory.newInstance();
        }
        catch (DatatypeConfigurationException e)
        {
            throw new IllegalArgumentException("Aspect conversation exception: " + e.getMessage(), e);
        }
        return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat();
    }

    // MNT-12496 MNT-15044
    // Filter for AtomPub and Web services bindings only. Browser/json binding already encodes.
    if (AlfrescoCmisServiceCall.get() != null &&
            (CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) ||
             CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding())))
    {
    	return filterXmlRestrictedCharacters(value.toString());
    }
    else
    {
    	return value.toString();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:CMISConnector.java

示例11: testNewDurationYearMonthLexicalRepresentation

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@Test
public void testNewDurationYearMonthLexicalRepresentation() throws DatatypeConfigurationException {
    DatatypeFactory dtf = DatatypeFactory.newInstance();
    Duration d = dtf.newDurationYearMonth("P20Y15M");
    int years = d.getYears();
    Assert.assertTrue(years == 21, "Return value should be normalized");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Bug6937964Test.java

示例12: testNewDurationDayTimeMilliseconds

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@Test
public void testNewDurationDayTimeMilliseconds() throws DatatypeConfigurationException {
    DatatypeFactory dtf = DatatypeFactory.newInstance();
    Duration d = dtf.newDurationDayTime(172805000L);
    int days = d.getDays();
    Assert.assertTrue(days == 2, "Return value should be normalized");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Bug6937964Test.java

示例13: testNewDurationYearMonthBigInteger

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@Test
public void testNewDurationYearMonthBigInteger() throws DatatypeConfigurationException {
    DatatypeFactory dtf = DatatypeFactory.newInstance();
    BigInteger year = new BigInteger("20");
    BigInteger mon = new BigInteger("15");
    Duration d = dtf.newDurationYearMonth(true, year, mon);
    int years = d.getYears();
    Assert.assertTrue(years == 21, "Return value should be normalized");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Bug6937964Test.java

示例14: onCreate

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
@Override
public void onCreate(TaskInfo taskInfo) {
    String taskDefinitionKey = taskInfo.getCode();

    String processDefinitionId = taskInfo.getProcessDefinitionId();
    List<DeadlineDTO> deadlines = taskDefinitionConnector.findDeadlines(
            taskDefinitionKey, processDefinitionId);

    for (DeadlineDTO deadline : deadlines) {
        try {
            String durationText = deadline.getDuration();

            Date now = new Date();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(now);

            DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
            Duration duration = datatypeFactory.newDuration(durationText);
            duration.addTo(calendar);

            Date deadlineTime = calendar.getTime();
            TaskDeadline taskDeadline = new TaskDeadline();
            taskDeadline.setTaskInfo(taskInfo);
            taskDeadline.setType(deadline.getType());
            taskDeadline.setDeadlineTime(deadlineTime);
            taskDeadline
                    .setNotificationType(deadline.getNotificationType());
            taskDeadline.setNotificationTemplateCode(deadline
                    .getNotificationTemplateCode());
            taskDeadline.setNotificationReceiver(deadline
                    .getNotificationReceiver());
            taskDeadlineManager.save(taskDeadline);
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:38,代码来源:DeadlineHumanTaskListener.java

示例15: newDurationDayTimeTester

import javax.xml.datatype.DatatypeFactory; //导入方法依赖的package包/类
private void newDurationDayTimeTester(boolean isPositive, boolean normalizedIsPositive, BigInteger years, BigInteger normalizedYears, BigInteger months,
        BigInteger normalizedMonths, BigInteger days, BigInteger normalizedDays, BigInteger hours, BigInteger normalizedHours, BigInteger minutes,
        BigInteger normalizedMinutes, BigDecimal seconds, BigDecimal normalizedSeconds, long durationInMilliSeconds, long normalizedDurationInMilliSeconds,
        String lexicalRepresentation, String normalizedLexicalRepresentation) {

    DatatypeFactory datatypeFactory = null;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException ex) {
        ex.printStackTrace();
        Assert.fail(ex.toString());
    }

    // create 4 dayTime Durations using the 4 different constructors

    Duration durationDayTimeBigInteger = datatypeFactory.newDurationDayTime(isPositive, days, hours, minutes, seconds.toBigInteger());
    durationAssertEquals(durationDayTimeBigInteger, DatatypeConstants.DURATION_DAYTIME, normalizedIsPositive, normalizedYears.intValue(),
            normalizedMonths.intValue(), normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(),
            normalizedDurationInMilliSeconds, normalizedLexicalRepresentation);

    /*
     * Duration durationDayTimeInt = datatypeFactory.newDurationDayTime(
     * isPositive, days.intValue(), hours.intValue(), minutes.intValue(),
     * seconds.intValue()); Duration durationDayTimeMilliseconds =
     * datatypeFactory.newDurationDayTime( durationInMilliSeconds); Duration
     * durationDayTimeLexical = datatypeFactory.newDurationDayTime(
     * lexicalRepresentation);
     * Duration durationYearMonthBigInteger =
     * datatypeFactory.newDurationYearMonth( isPositive, years, months);
     * Duration durationYearMonthInt = datatypeFactory.newDurationYearMonth(
     * isPositive, years.intValue(), months.intValue()); Duration
     * durationYearMonthMilliseconds = datatypeFactory.newDurationYearMonth(
     * durationInMilliSeconds); Duration durationYearMonthLexical =
     * datatypeFactory.newDurationYearMonth( lexicalRepresentation) ;
     */

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:DurationTest.java


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