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


Java XMLGregorianCalendar.toString方法代码示例

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


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

示例1: main

import javax.xml.datatype.XMLGregorianCalendar; //导入方法依赖的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

示例2: dataCte

import javax.xml.datatype.XMLGregorianCalendar; //导入方法依赖的package包/类
public static String dataCte(LocalDateTime data) throws CteException {
	XMLGregorianCalendar xmlCalendar;
	try {
		GregorianCalendar calendar = GregorianCalendar.from(data.atZone(ZoneId.of("Brazil/East")));

		xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
		xmlCalendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);

	} catch (DatatypeConfigurationException e) {
		throw new CteException(e.getMessage());
	}

	return (xmlCalendar.toString());
}
 
开发者ID:Samuel-Oliveira,项目名称:Java_CTe,代码行数:15,代码来源:XmlUtil.java

示例3: testToString

import javax.xml.datatype.XMLGregorianCalendar; //导入方法依赖的package包/类
@Test
public void testToString() {
    try {
        String inputDateTime = "2006-10-23T22:15:01.000000135+08:00";
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(inputDateTime);
        String toStr = calendar.toString();
        Assert.assertTrue(toStr.indexOf("E") == -1, "String value cannot contain exponent");
    } catch (DatatypeConfigurationException dce) {
        dce.printStackTrace();
        Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:XMLGregorianCalendarTest.java

示例4: checkToStringPos

import javax.xml.datatype.XMLGregorianCalendar; //导入方法依赖的package包/类
@Test(dataProvider = "calendar")
public void checkToStringPos(final int year, final int month, final int day, final int hour, final int minute, final int second) {
    XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(year, month, day, hour, minute, second, undef, undef);
    calendar.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XMLGregorianCalendarTest.java

示例5: checkToStringNeg

import javax.xml.datatype.XMLGregorianCalendar; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalStateException.class)
public void checkToStringNeg() {
    XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(undef, undef, undef, undef, undef, undef, undef, undef);
    // expected to fail
    calendar.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XMLGregorianCalendarTest.java


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