本文整理匯總了Java中javax.xml.datatype.XMLGregorianCalendar.getMonth方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLGregorianCalendar.getMonth方法的具體用法?Java XMLGregorianCalendar.getMonth怎麽用?Java XMLGregorianCalendar.getMonth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.datatype.XMLGregorianCalendar
的用法示例。
在下文中一共展示了XMLGregorianCalendar.getMonth方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hashCode
import javax.xml.datatype.XMLGregorianCalendar; //導入方法依賴的package包/類
/**
* <p>Returns a hash code consistent with the definition of the equals method.</p>
*
* @return hash code of this object.
*/
public int hashCode() {
// Following two dates compare to EQUALS since in different timezones.
// 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00
//
// Must ensure both instances generate same hashcode by normalizing
// this to UTC timezone.
int timezone = getTimezone();
if (timezone == DatatypeConstants.FIELD_UNDEFINED) {
timezone = 0;
}
XMLGregorianCalendar gc = this;
if (timezone != 0) {
gc = this.normalizeToTimezone(getTimezone());
}
return gc.getYear() + gc.getMonth() + gc.getDay() +
gc.getHour() + gc.getMinute() + gc.getSecond();
}
示例2: checkXmlGregorianCalendarFieldRef
import javax.xml.datatype.XMLGregorianCalendar; //導入方法依賴的package包/類
private static void checkXmlGregorianCalendarFieldRef(QName type,
XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{
StringBuilder buf = new StringBuilder();
int bitField = xmlGregorianCalendarFieldRef.get(type);
final int l = 0x1;
int pos = 0;
while (bitField != 0x0){
int bit = bitField & l;
bitField >>>= 4;
pos++;
if (bit == 1) {
switch(pos){
case 1:
if (cal.getSecond() == DatatypeConstants.FIELD_UNDEFINED){
buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_SEC);
}
break;
case 2:
if (cal.getMinute() == DatatypeConstants.FIELD_UNDEFINED){
buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MIN);
}
break;
case 3:
if (cal.getHour() == DatatypeConstants.FIELD_UNDEFINED){
buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_HR);
}
break;
case 4:
if (cal.getDay() == DatatypeConstants.FIELD_UNDEFINED){
buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_DAY);
}
break;
case 5:
if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){
buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MONTH);
}
break;
case 6:
if (cal.getYear() == DatatypeConstants.FIELD_UNDEFINED){
buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_YEAR);
}
break;
case 7: // ignore timezone setting
break;
}
}
}
if (buf.length() > 0){
throw new javax.xml.bind.MarshalException(
Messages.XMLGREGORIANCALENDAR_INVALID.format(type.getLocalPart())
+ buf.toString());
}
}