本文整理汇总了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();
}