當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。