本文整理匯總了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());
}
}
示例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());
}
示例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());
}
}
示例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();
}
示例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();
}