本文整理匯總了Java中javax.xml.datatype.DatatypeConstants.DATETIME屬性的典型用法代碼示例。如果您正苦於以下問題:Java DatatypeConstants.DATETIME屬性的具體用法?Java DatatypeConstants.DATETIME怎麽用?Java DatatypeConstants.DATETIME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.xml.datatype.DatatypeConstants
的用法示例。
在下文中一共展示了DatatypeConstants.DATETIME屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toXMLFormat
/**
* <p>Return the lexical representation of <code>this</code> instance.
* The format is specified in
* <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
* <i>Lexical Representation</i>".</a></p>
*
* <p>Specific target lexical representation format is determined by
* {@link #getXMLSchemaType()}.</p>
*
* @return XML, as <code>String</code>, representation of this <code>XMLGregorianCalendar</code>
*
* @throws java.lang.IllegalStateException if the combination of set fields
* does not match one of the eight defined XML Schema builtin date/time datatypes.
*/
public String toXMLFormat() {
QName typekind = getXMLSchemaType();
String formatString = null;
// Fix 4971612: invalid SCCS macro substitution in data string
// no %{alpha}% to avoid SCCS macro substitution
if (typekind == DatatypeConstants.DATETIME) {
formatString = "%Y-%M-%DT%h:%m:%s" + "%z";
} else if (typekind == DatatypeConstants.DATE) {
formatString = "%Y-%M-%D" + "%z";
} else if (typekind == DatatypeConstants.TIME) {
formatString = "%h:%m:%s" + "%z";
} else if (typekind == DatatypeConstants.GMONTH) {
formatString = "--%M" + "%z";
} else if (typekind == DatatypeConstants.GDAY) {
formatString = "---%D" + "%z";
} else if (typekind == DatatypeConstants.GYEAR) {
formatString = "%Y" + "%z";
} else if (typekind == DatatypeConstants.GYEARMONTH) {
formatString = "%Y-%M" + "%z";
} else if (typekind == DatatypeConstants.GMONTHDAY) {
formatString = "--%M-%D" + "%z";
}
return format(formatString);
}