gpt4 book ai didi

com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 23:55:05 25 4
gpt4 key购买 nike

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

XMLGregorianCalendarImpl介绍

[英]Representation for W3C XML Schema 1.0 date/time datatypes. Specifically, these date/time datatypes are DatatypeConstants#DATETIME, DatatypeConstants#TIME, DatatypeConstants#DATE, DatatypeConstants#GYEARMONTH, DatatypeConstants#GMONTHDAY, DatatypeConstants#GYEAR, DatatypeConstants#GMONTH and DatatypeConstants#GDAYdefined in the XML Namespace "http://www.w3.org/2001/XMLSchema". These datatypes are normatively defined in W3C XML Schema 1.0 Part 2, Section 3.2.7-14.

The table below defines the mapping between XML Schema 1.0 date/time datatype fields and this class' fields. It also summarizes the value constraints for the date and time fields defined in W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats.
Date/time datatype field mapping between XML Schema 1.0 and Java representation XML Schema 1.0
datatype
fieldRelated
XMLGregorianCalendar
Accessor(s)Value Range{{$2$}}year #getYear() + #getEon() or
#getEonAndYeargetYear() is a value between -(10^9-1) to (10^9)-1 or DatatypeConstants#FIELD_UNDEFINED.
#getEon() is high order year value in billion of years.
getEon() has values greater than or equal to (10^9) or less than or equal to -(10^9). A value of null indicates field is undefined.
Given that {{$3$}} states that the year zero will be a valid lexical value in a future version of XML Schema, this class allows the year field to be set to zero. Otherwise, the year field value is handled exactly as described in the errata and [ISO-8601-1988]. Note that W3C XML Schema 1.0 validation does not allow for the year field to have a value of zero. {{$4$}}month #getMonth() 1 to 12 or DatatypeConstants#FIELD_UNDEFINED {{$5$}}day #getDay() Independent of month, max range is 1 to 31 or DatatypeConstants#FIELD_UNDEFINED.
The normative value constraint stated relative to month field's value is in {{$6$}}. {{$7$}}hour #getHour() 0 to 23 or DatatypeConstants#FIELD_UNDEFINED. An hour value of 24 is allowed to be set in the lexical space provided the minute and second field values are zero. However, an hour value of 24 is not allowed in value space and will be transformed to represent the value of the first instance of the following day as per {{$8$}}. {{$9$}}minute #getMinute() 0 to 59 or DatatypeConstants#FIELD_UNDEFINED {{$10$}}second#getSecond() + #getMillisecond()/1000 or
#getSecond() + #getFractionalSecond()#getSecond() from 0 to 60 or DatatypeConstants#FIELD_UNDEFINED.
(Note: 60 only allowable for leap second.)
#getFractionalSecond() allows for infinite precision over the range from 0.0 to 1.0 when the #getSecond() is defined.
FractionalSecond is optional and has a value of null when it is undefined.
#getMillisecond() is the convenience millisecond precision of value of #getFractionalSecond(). timezone #getTimezone() Number of minutes or DatatypeConstants#FIELD_UNDEFINED. Value range from -14 hours (-14 * 60 minutes) to 14 hours (14 * 60 minutes).

All maximum value space constraints listed for the fields in the table above are checked by factory methods, setter methods and parse methods of this class. IllegalArgumentException is thrown when parameter's value is outside the maximum value constraint for the field. Validation checks, for example, whether days in month should be limited to 29, 30 or 31 days, that are dependent on the values of other fields are not checked by these methods.

The following operations are defined for this class:

代码示例

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
 * <p>Create a new instance of an <code>XMLGregorianCalendar</code>.</p>
 * 
 * <p>All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null.</p>
 * 
 * @return New <code>XMLGregorianCalendar</code> with all date/time datatype fields set to
 *   {@link DatatypeConstants#FIELD_UNDEFINED} or null.
 */
public XMLGregorianCalendar newXMLGregorianCalendar() {
  
  return new XMLGregorianCalendarImpl();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

private void testHour() {
  // http://www.w3.org/2001/05/xmlschema-errata#e2-45
  if (getHour() == 24) {
    if (getMinute() != 0
        || getSecond() != 0) {
      invalidFieldValue(HOUR, getHour());
    }
    // while 0-24 is acceptable in the lexical space, 24 is not valid in value space
    // W3C XML Schema Part 2, Section 3.2.7.1
    setHour(0, false);
    add(new DurationImpl(true, 0, 0, 1, 0, 0, 0));
  }
}

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
 * <p>Indicates whether parameter <code>obj</code> is "equal to" this one.</p>
 *
 * @param obj to compare.
 *
 * @return <code>true</code> when <code>compare(this,(XMLGregorianCalendar)obj) == EQUAL.</code>.
 */
public boolean equals(Object obj) {
  
if (obj == null || !(obj instanceof XMLGregorianCalendar)) {
  return false;
}
return compare((XMLGregorianCalendar) obj) == DatatypeConstants.EQUAL;
}

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
 * <p>Creates and returns a copy of this object.</p>
 *
 * @return copy of this <code>Object</code>
 */
public Object clone() {
  // Both this.eon and this.fractionalSecond are instances
  // of immutable classes, so they do not need to be cloned.
  return new XMLGregorianCalendarImpl(getEonAndYear(),
          this.month, this.day,
    this.hour, this.minute, this.second,
    this.fractionalSecond,
    this.timezone);
}

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

QName typekind = getXMLSchemaType();
  formatString = "--%M-%D" + "%z";
return format(formatString);

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

int startMonth = getMonth();
if (startMonth == DatatypeConstants.FIELD_UNDEFINED) {
  startMonth = DatatypeConstants.JANUARY;
BigInteger dMonths = sanitize(duration.getField(DatatypeConstants.MONTHS), signum);
BigInteger temp = BigInteger.valueOf((long) startMonth).add(dMonths);
setMonth(temp.subtract(BigInteger.ONE).mod(TWELVE).intValue() + 1);
BigInteger carry =
    new BigDecimal(temp.subtract(BigInteger.ONE)).divide(new BigDecimal(TWELVE), BigDecimal.ROUND_FLOOR).toBigInteger();
BigInteger startYear = getEonAndYear();
if (startYear == null) {
  fieldUndefined[YEAR] = true;
  startYear = BigInteger.ZERO;
BigInteger dYears = sanitize(duration.getField(DatatypeConstants.YEARS), signum);
BigInteger endYear = startYear.add(dYears).add(carry);
setYear(endYear);
if (getSecond() == DatatypeConstants.FIELD_UNDEFINED) {
  fieldUndefined[SECOND] = true;
  startSeconds = DECIMAL_ZERO;
} else {
  startSeconds = getSeconds();
setSecond(endSeconds.intValue());
BigDecimal tempFracSeconds = endSeconds.subtract(new BigDecimal(BigInteger.valueOf((long) getSecond())));
if (tempFracSeconds.compareTo(DECIMAL_ZERO) < 0) {

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

int y = getYear();
    if(y<0) {
      buf[bufPtr++] = '-';
      y = -y;
    bufPtr = print4Number(buf,bufPtr,y);
  } else {
    String s = getEonAndYear().toString();
  bufPtr = print2Number(buf,bufPtr,getMonth());
  break;
case 'D':
  bufPtr = print2Number(buf,bufPtr,getDay());
  break;
case 'h':
  bufPtr = print2Number(buf,bufPtr,getHour());
  break;
case 'm':
  bufPtr = print2Number(buf,bufPtr,getMinute());
  break;
case 's':
  bufPtr = print2Number(buf,bufPtr,getSecond());
  if (getFractionalSecond() != null) {
    String frac = getFractionalSecond().toString();
  int offset = getTimezone();
  if (offset == 0) {
    buf[bufPtr++] = 'Z';

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

if (getMonth() == DatatypeConstants.FEBRUARY) {
        maxDays = maximumDayInMonthFor(year,getMonth());
    } else {
      BigInteger years = getEonAndYear();
      if (years != null) {
        maxDays = maximumDayInMonthFor(getEonAndYear(), DatatypeConstants.FEBRUARY);
    if (getDay() > maxDays) {
      return false;
if (getHour() == 24) {
  if(getMinute() != 0) {
  return false;
  } else if (getSecond() != 0) {
  return false;
  BigInteger yearField = getEonAndYear();
  if (yearField != null) {
  int result = compareField(yearField, BigInteger.ZERO);
  if (result == DatatypeConstants.EQUAL) {
    return false;

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

TimeZone tz = getTimeZone(DEFAULT_TIMEZONE_OFFSET);
Locale locale = Locale.getDefault();
BigInteger year = getEonAndYear();
if (year != null) {
  result.set(Calendar.ERA, year.signum() == -1 ? GregorianCalendar.BC : GregorianCalendar.AD);
  result.set(Calendar.MILLISECOND, getMillisecond());

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

createDateTime(
  400,  //year
DatatypeConstants.JANUARY,  //month
int timezone) {
return new XMLGregorianCalendarImpl(
  year,
  month,
int timezone) {
return new XMLGregorianCalendarImpl(
  year,
  month,

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

/**
 * <p>Normalize this instance to UTC.</p>
 *
 * <p>2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z</p>
 * <p>Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).</p>
 */
private XMLGregorianCalendar normalizeToTimezone(int timezone) {
  int minutes = timezone;
  XMLGregorianCalendar result = (XMLGregorianCalendar) this.clone();
  // normalizing to UTC time negates the timezone offset before
  // addition.
  minutes = -minutes;
  Duration d = new DurationImpl(minutes >= 0, // isPositive
      0, //years
      0, //months
      0, //days
      0, //hours
      minutes < 0 ? -minutes : minutes, // absolute
      0  //seconds
  );
  result.add(d);
  // set to zulu UTC time.
  result.setTimezone(0);
  return result;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

result = compareField(P.getYear(), Q.getYear());
  if (result != DatatypeConstants.EQUAL) {
    return result;
  result = compareField(P.getEonAndYear(), Q.getEonAndYear());
  if (result != DatatypeConstants.EQUAL) {
    return result;
result = compareField(P.getMonth(), Q.getMonth());
if (result != DatatypeConstants.EQUAL) {
  return result;
result = compareField(P.getDay(), Q.getDay());
if (result != DatatypeConstants.EQUAL) {
  return result;
result = compareField(P.getHour(), Q.getHour());
if (result != DatatypeConstants.EQUAL) {
  return result;
result = compareField(P.getMinute(), Q.getMinute());
if (result != DatatypeConstants.EQUAL) {
  return result;
result = compareField(P.getSecond(), Q.getSecond());
if (result != DatatypeConstants.EQUAL) {
  return result;
result = compareField(P.getFractionalSecond(), Q.getFractionalSecond());

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

int startMonth = getMonth();
if (startMonth == DatatypeConstants.FIELD_UNDEFINED) {
  startMonth = DatatypeConstants.JANUARY;
BigInteger dMonths = sanitize(duration.getField(DatatypeConstants.MONTHS), signum);
BigInteger temp = BigInteger.valueOf((long) startMonth).add(dMonths);
setMonth(temp.subtract(BigInteger.ONE).mod(TWELVE).intValue() + 1);
BigInteger carry =
    new BigDecimal(temp.subtract(BigInteger.ONE)).divide(new BigDecimal(TWELVE), BigDecimal.ROUND_FLOOR).toBigInteger();
BigInteger startYear = getEonAndYear();
if (startYear == null) {
  fieldUndefined[YEAR] = true;
  startYear = BigInteger.ZERO;
BigInteger dYears = sanitize(duration.getField(DatatypeConstants.YEARS), signum);
BigInteger endYear = startYear.add(dYears).add(carry);
setYear(endYear);
if (getSecond() == DatatypeConstants.FIELD_UNDEFINED) {
  fieldUndefined[SECOND] = true;
  startSeconds = DECIMAL_ZERO;
} else {
  startSeconds = getSeconds();
setSecond(endSeconds.intValue());
BigDecimal tempFracSeconds = endSeconds.subtract(new BigDecimal(BigInteger.valueOf((long) getSecond())));
if (tempFracSeconds.compareTo(DECIMAL_ZERO) < 0) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

int y = getYear();
    if(y<0) {
      buf[bufPtr++] = '-';
      y = -y;
    bufPtr = print4Number(buf,bufPtr,y);
  } else {
    String s = getEonAndYear().toString();
  bufPtr = print2Number(buf,bufPtr,getMonth());
  break;
case 'D':
  bufPtr = print2Number(buf,bufPtr,getDay());
  break;
case 'h':
  bufPtr = print2Number(buf,bufPtr,getHour());
  break;
case 'm':
  bufPtr = print2Number(buf,bufPtr,getMinute());
  break;
case 's':
  bufPtr = print2Number(buf,bufPtr,getSecond());
  if (getFractionalSecond() != null) {
    String frac = getFractionalSecond().toString();
  int offset = getTimezone();
  if (offset == 0) {
    buf[bufPtr++] = 'Z';

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

if (getMonth() == DatatypeConstants.FEBRUARY) {
        maxDays = maximumDayInMonthFor(year,getMonth());
    } else {
      BigInteger years = getEonAndYear();
      if (years != null) {
        maxDays = maximumDayInMonthFor(getEonAndYear(), DatatypeConstants.FEBRUARY);
    if (getDay() > maxDays) {
      return false;
if (getHour() == 24) {
  if(getMinute() != 0) {
  return false;
  } else if (getSecond() != 0) {
  return false;
  BigInteger yearField = getEonAndYear();
  if (yearField != null) {
  int result = compareField(yearField, BigInteger.ZERO);
  if (result == DatatypeConstants.EQUAL) {
    return false;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

TimeZone tz = getTimeZone(DEFAULT_TIMEZONE_OFFSET);
Locale locale = Locale.getDefault();
BigInteger year = getEonAndYear();
if (year != null) {
  result.set(Calendar.ERA, year.signum() == -1 ? GregorianCalendar.BC : GregorianCalendar.AD);
  result.set(Calendar.MILLISECOND, getMillisecond());

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/**
 * <p>Creates and returns a copy of this object.</p>
 *
 * @return copy of this <code>Object</code>
 */
public Object clone() {
  // Both this.eon and this.fractionalSecond are instances
  // of immutable classes, so they do not need to be cloned.
  return new XMLGregorianCalendarImpl(getEonAndYear(),
          this.month, this.day,
    this.hour, this.minute, this.second,
    this.fractionalSecond,
    this.timezone);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

createDateTime(
  400,  //year
DatatypeConstants.JANUARY,  //month
int timezone) {
return new XMLGregorianCalendarImpl(
  year,
  month,
int timezone) {
return new XMLGregorianCalendarImpl(
  year,
  month,

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

QName typekind = getXMLSchemaType();
  formatString = "--%M-%D" + "%z";
return format(formatString);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/**
 * <p>Normalize this instance to UTC.</p>
 *
 * <p>2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z</p>
 * <p>Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).</p>
 */
private XMLGregorianCalendar normalizeToTimezone(int timezone) {
  int minutes = timezone;
  XMLGregorianCalendar result = (XMLGregorianCalendar) this.clone();
  // normalizing to UTC time negates the timezone offset before
  // addition.
  minutes = -minutes;
  Duration d = new DurationImpl(minutes >= 0, // isPositive
      0, //years
      0, //months
      0, //days
      0, //hours
      minutes < 0 ? -minutes : minutes, // absolute
      0  //seconds
  );
  result.add(d);
  // set to zulu UTC time.
  result.setTimezone(0);
  return result;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com