javax.xml.datatype.XMLGregorianCalendar.getMonth()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中javax.xml.datatype.XMLGregorianCalendar.getMonth()方法的一些代码示例,展示了XMLGregorianCalendar.getMonth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLGregorianCalendar.getMonth()方法的具体详情如下:
包路径:javax.xml.datatype.XMLGregorianCalendar
类名称:XMLGregorianCalendar
方法名:getMonth

XMLGregorianCalendar.getMonth介绍

[英]Return number of month or DatatypeConstants#FIELD_UNDEFINED.

Value constraints for this value are summarized in month field of date/time field mapping table.
[中]返回未定义的月份数或DatatypeConstants#字段_。
此值的值约束汇总在month field of date/time field mapping table中。

代码示例

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){
  buf.append("  ").append(Messages.XMLGREGORIANCALENDAR_MONTH);

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

break;
case 'M':
  printNumber(buf,value.getMonth(),2);
  break;
case 'D':

代码示例来源:origin: robovm/robovm

/**
 * <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.normalize();
  }
  return gc.getYear()
  + gc.getMonth()
  + gc.getDay()
  + gc.getHour()
  + gc.getMinute()
  + gc.getSecond();
}

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){
  buf.append("  ").append(Messages.XMLGREGORIANCALENDAR_MONTH);

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

break;
case 'M':
  printNumber(buf,value.getMonth(),2);
  break;
case 'D':

代码示例来源:origin: org.eclipse.emf/org.eclipse.emf.ecore

@Override
public int getMonth()
{
 return xmlGregorianCalendar.getMonth();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.emf.ecore

@Override
public int getMonth()
{
 return xmlGregorianCalendar.getMonth();
}

代码示例来源:origin: goldmansachs/jdmn

public BigDecimal month(XMLGregorianCalendar date) {
  if (date == null) {
    return null;
  }
  try {
    return BigDecimal.valueOf(date.getMonth());
  } catch (Exception e) {
    String message = String.format("month(%s)", date);
    logError(message, e);
    return null;
  }
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

public BigDecimal month(XMLGregorianCalendar date) {
  if (date == null) {
    return null;
  }
  try {
    return BigDecimal.valueOf(date.getMonth());
  } catch (Exception e) {
    String message = String.format("month(%s)", date);
    logError(message, e);
    return null;
  }
}

代码示例来源:origin: ORCID/ORCID-Source

private static Date getCreatedDate(XMLGregorianCalendar calendar) {
  if (calendar != null) {
    int year = calendar.getYear();
    int month = calendar.getMonth();
    int day = calendar.getDay();
    return Date.valueOf(FuzzyDate.valueOf(year, month, day));
  }
  return null;
}

代码示例来源:origin: apache/marmotta

@Override
public Date dateValue(Value node) {
  try {
    XMLGregorianCalendar cal = ((Literal)node).calendarValue();
    return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime();
  } catch (ClassCastException e) {
    throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
        "but of type "+debugType(node));
  }
}

代码示例来源:origin: apache/marmotta

@Override
public Date dateValue(Value node) {
  try {
    XMLGregorianCalendar cal = ((Literal)node).calendarValue();
    return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime();
  } catch (ClassCastException e) {
    throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
        "but of type "+debugType(node));
  }
}

代码示例来源:origin: org.apache.marmotta/ldpath-backend-sesame

@Override
public Date dateValue(Value node) {
  try {
    XMLGregorianCalendar cal = ((Literal)node).calendarValue();
    return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime();
  } catch (ClassCastException e) {
    throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
        "but of type "+debugType(node));
  }
}

代码示例来源:origin: be.fedict.eid-trust-service/eid-trust-service-xkms2-ws-impl

private Date getDate(XMLGregorianCalendar xmlCalendar) {
  GregorianCalendar calendar = new GregorianCalendar(
      xmlCalendar.getYear(),
      xmlCalendar.getMonth() - 1,
      xmlCalendar.getDay(), //
      xmlCalendar.getHour(), xmlCalendar.getMinute(),
      xmlCalendar.getSecond());
  calendar.setTimeZone(xmlCalendar.getTimeZone(0));
  return calendar.getTime();
}

代码示例来源:origin: palominolabs/sf-api-connector

/**
   * Convert an {@link XMLGregorianCalendar} (assumed to be in UTC) into a {@link DateTime}.
   *
   * @param soapTime the UTC timestamp extracted from the SF soap layer
   *
   * @return a DateTime object representing the same time as the original soapTime
   */
  public static DateTime convertSFTimeToDateTime(XMLGregorianCalendar soapTime) {
    return new DateTime(soapTime.getYear(), soapTime.getMonth(), soapTime.getDay(), soapTime.getHour(),
        soapTime.getMinute(), soapTime.getSecond(), soapTime.getMillisecond(), DateTimeZone.UTC);
  }
}

代码示例来源:origin: rocks.xmpp/xmpp-extensions-common

/**
 * Gets the value as date or null.
 *
 * @return The date or null.
 */
public final OffsetDateTime getAsInstant() {
  if (value instanceof XMLGregorianCalendar) {
    XMLGregorianCalendar calendar = (XMLGregorianCalendar) value;
    return OffsetDateTime.of(calendar.getYear(), calendar.getMonth(), calendar.getDay(), calendar.getHour(), calendar.getMinute(), calendar.getSecond(), 0, ZoneOffset.ofTotalSeconds(calendar.getTimezone() * 60));
  }
  return null;
}

代码示例来源:origin: goldmansachs/jdmn

public static boolean isValidTime(XMLGregorianCalendar calendar) {
  if (calendar == null) {
    return false;
  }
  return
      isValidTime(calendar.getHour(), calendar.getMinute(), calendar.getSecond())
          && isUndefined(calendar.getYear())
          && isUndefined(calendar.getMonth())
          && isUndefined(calendar.getDay())
      ;
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

public static boolean isValidTime(XMLGregorianCalendar calendar) {
  if (calendar == null) {
    return false;
  }
  return
      isValidTime(calendar.getHour(), calendar.getMinute(), calendar.getSecond())
          && isUndefined(calendar.getYear())
          && isUndefined(calendar.getMonth())
          && isUndefined(calendar.getDay())
      ;
}

代码示例来源:origin: apache/cxf

protected boolean equalsDate(XMLGregorianCalendar orig, XMLGregorianCalendar actual) {
  boolean result = false;
  if ((orig.getYear() == actual.getYear()) && (orig.getMonth() == actual.getMonth())
    && (orig.getDay() == actual.getDay()) && (actual.getHour() == DatatypeConstants.FIELD_UNDEFINED)
    && (actual.getMinute() == DatatypeConstants.FIELD_UNDEFINED)
    && (actual.getSecond() == DatatypeConstants.FIELD_UNDEFINED)
    && (actual.getMillisecond() == DatatypeConstants.FIELD_UNDEFINED)) {
    result = orig.getTimezone() == actual.getTimezone();
  }
  return result;
}

代码示例来源:origin: apache/cxf

protected boolean equalsDateTime(XMLGregorianCalendar orig, XMLGregorianCalendar actual) {
  boolean result = false;
  if ((orig.getYear() == actual.getYear()) && (orig.getMonth() == actual.getMonth())
    && (orig.getDay() == actual.getDay()) && (orig.getHour() == actual.getHour())
    && (orig.getMinute() == actual.getMinute()) && (orig.getSecond() == actual.getSecond())
    && (orig.getMillisecond() == actual.getMillisecond())) {
    result = orig.getTimezone() == actual.getTimezone();
  }
  return result;
}

相关文章