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

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

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

XMLGregorianCalendar.getMillisecond介绍

[英]Return millisecond precision of #getFractionalSecond().

This method represents a convenience accessor to infinite precision fractional second value returned by #getFractionalSecond(). The returned value is the rounded down to milliseconds value of #getFractionalSecond(). When #getFractionalSecond()returns null, this method must return DatatypeConstants#FIELD_UNDEFINED.

Value constraints for this value are summarized in second field of date/time field mapping table.
[中]返回#GetFractilSecond()的毫秒精度。
此方法表示对#GetFractilSecond()返回的无限精度分数秒值的方便访问器。返回的值是#GetFractilSecond()的四舍五入到毫秒的值。当#getFractilSecond()返回[$0$]时,此方法必须返回DatatypeConstants#字段_UNDEFINED。
此值的值约束汇总在second field of date/time field mapping table中。

代码示例

代码示例来源:origin: psidev.psi.mi/psi25-xml

public int getMillisecond() {
  return calendar.getMillisecond();
}

代码示例来源:origin: psidev.psi.mi/psi25-xml

public int getMillisecond() {
  return calendar.getMillisecond();
}

代码示例来源:origin: org.openrdf.mulgara/mulgara-query

/**
 * Returns the lexical form of the XSD dateTime value according to
 * "3.2.7.2 Canonical representation" of
 * http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/
 * with the following exceptions:
 * - Timezones are not supported
 * - Dates before 1 CE (i.e. 1 AD) are handled according to ISO 8601:2000
 *   Second Edition:
 *     "0000" is the lexical representation of 1 BCE
 *     "-0001" is the lexical representation of 2 BCE
 * @return the lexical form of the XSD dateTime value
 */
public static String getLexicalForm(Date date) {
  GregorianCalendar gc = new GregorianCalendar(0, 0, 0);
  gc.setTime(date);
  XMLGregorianCalendar xgc = factory.newXMLGregorianCalendar(gc);
  xgc.setTimezone(FIELD_UNDEFINED);
  if (xgc.getMillisecond() == 0) {
    xgc.setMillisecond(FIELD_UNDEFINED);
  }
  return xgc.toXMLFormat();
}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
   * Converts the date to the object to be marshalled in a XML file or stream.
   * JAXB calls automatically this method at marshalling time.
   *
   * @param  value  the {@code java.util} date value, or {@code null}.
   * @return the XML date, or {@code null}.
   */
  @Override
  public XMLGregorianCalendar marshal(final Date value) {
    if (value != null) {
      final GregorianCalendar calendar = new GregorianCalendar(UTC, Locale.ROOT);
      calendar.setTime(value);
      try {
        final XMLGregorianCalendar gc = getDatatypeFactory().newXMLGregorianCalendar(calendar);
        if (gc.getMillisecond() == 0) {
          gc.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
        }
        return gc;
      } catch (DatatypeConfigurationException e) {
        Context.warningOccured(Context.current(), XmlAdapter.class, "marshal", e, true);
      }
    }
    return null;
  }
}

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

/**
   * Converts the date to the object to be marshalled in a XML file or stream.
   * JAXB calls automatically this method at marshalling time.
   *
   * @param  value  the {@code java.util} date value, or {@code null}.
   * @return the XML date, or {@code null}.
   */
  @Override
  public XMLGregorianCalendar marshal(final Date value) {
    if (value != null) {
      final GregorianCalendar calendar = new GregorianCalendar(UTC, Locale.ROOT);
      calendar.setTime(value);
      try {
        final XMLGregorianCalendar gc = XmlUtilities.getDatatypeFactory().newXMLGregorianCalendar(calendar);
        if (gc.getMillisecond() == 0) {
          gc.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
        }
        return gc;
      } catch (DatatypeConfigurationException e) {
        Context.warningOccured(Context.current(), XmlAdapter.class, "marshal", e, true);
      }
    }
    return null;
  }
}

代码示例来源:origin: stackoverflow.com

public XMLGregorianCalendar getDate(final XMLGregorianCalendar date, final XMLGregorianCalendar time) {

XMLGregorianCalendar date = null;
if (date != null && time != null) {
 try {
  newDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(date.getYear(), date.getMonth(),     date.getDay(),
  time.getHour(), time.getMinute(), time.getSecond(), time.getMillisecond(), 0);
  Duration duration = DatatypeFactory.newInstance().newDurationDayTime(true, 0, 13, 0, 0);
  newDate.add(duration);
 }
 catch (Exception e) {
  LOGGER.error("Error creating date", e);
 }
}
return newDate;

代码示例来源:origin: net.sf.saxon/Saxon-HE

gc.set(Calendar.SECOND, second == DatatypeConstants.FIELD_UNDEFINED ? defaults.getSecond() : second);
gc.set(Calendar.MILLISECOND, microsecond == DatatypeConstants.FIELD_UNDEFINED
    ? defaults.getMillisecond() : microsecond / 1000);
return gc;

代码示例来源: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: org.eclipse.persistence/org.eclipse.persistence.core

cal.set(Calendar.MILLISECOND, xgc.getMillisecond());

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

cal.set(Calendar.MILLISECOND, xgc.getMillisecond());

代码示例来源:origin: com.seovic.coherence/pof

public static RawTime toRawTime(XMLGregorianCalendar time) {
  if (time == null) return null;
  int hourOffset   = 0;
  int minuteOffset = 0;
  int tz = time.getTimezone();
  if (tz != DatatypeConstants.FIELD_UNDEFINED) {
    hourOffset   = tz / 60;
    minuteOffset = tz % 60;
  }
  return new RawTime(time.getHour(),
            time.getMinute(),
            time.getSecond(),
            time.getMillisecond() * 1000000,
            hourOffset, minuteOffset);
}

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

if ( fs.doubleValue() != xcal.getMillisecond()/1000.0 )
    return -1 ;
v = time(v, xcal.getHour(), xcal.getMinute(), xcal.getSecond()*1000+xcal.getMillisecond()) ;

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

if ( fs.doubleValue() != xcal.getMillisecond() / 1000.0 )
    return -1;
v = time(v, xcal.getHour(), xcal.getMinute(), xcal.getSecond() * 1000 + xcal.getMillisecond());

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

protected boolean equalsTime(XMLGregorianCalendar orig, XMLGregorianCalendar actual) {
  boolean result = false;
  if ((orig.getHour() == actual.getHour()) && (orig.getMinute() == actual.getMinute())
    && (orig.getSecond() == actual.getSecond()) && (orig.getMillisecond() == actual.getMillisecond())
    && (orig.getTimezone() == actual.getTimezone())) {
    result = true;
  }
  return result;
}

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

/**
 * Builds a wrapper for the given {@link Date}.
 *
 * @param date  the date to marshal. Can not be {@code null}.
 */
private GO_DateTime(final Date date) {
  final Context context = Context.current();
  try {
    final XMLGregorianCalendar gc = XmlUtilities.toXML(context, date);
    if (Context.isFlagSet(context, Context.LEGACY_METADATA)) {
      if (XmlUtilities.trimTime(gc, false)) {
        this.date = gc;
      } else {
        dateTime = gc;
      }
    } else {
      if (gc.getMillisecond() == 0) {
        gc.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
      }
      dateTime = gc;
    }
  } catch (DatatypeConfigurationException e) {
    Context.warningOccured(context, XmlAdapter.class, "marshal", e, true);
  }
}

代码示例来源:origin: org.apache.sis.core/sis-utility

if (force || gc.getMillisecond() == 0) {
  gc.setMillisecond(FIELD_UNDEFINED);
  if (force || (gc.getHour() == 0 && gc.getMinute() == 0 && gc.getSecond() == 0)) {

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

if (force || gc.getMillisecond() == 0) {
  gc.setMillisecond(FIELD_UNDEFINED);
  if (force || (gc.getHour() == 0 && gc.getMinute() == 0 && gc.getSecond() == 0)) {

代码示例来源: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;
}

代码示例来源:origin: Talend/components

@Override
  public Object convertToAvro(XMLGregorianCalendar xts) {
    if (xts == null) {
      return null;
    }

    MutableDateTime dateTime = new MutableDateTime();
    try {
      dateTime.setYear(xts.getYear());
      dateTime.setMonthOfYear(xts.getMonth());
      dateTime.setDayOfMonth(xts.getDay());
      dateTime.setHourOfDay(xts.getHour());
      dateTime.setMinuteOfHour(xts.getMinute());
      dateTime.setSecondOfMinute(xts.getSecond());
      dateTime.setMillisOfSecond(xts.getMillisecond());

      DateTimeZone tz = DateTimeZone.forOffsetMillis(xts.getTimezone() * 60000);
      if (tz != null) {
        dateTime.setZoneRetainFields(tz);
      }

      return Long.valueOf(dateTime.getMillis());
    } catch (IllegalArgumentException e) {
      throw new ComponentException(e);
    }
  }
}

代码示例来源: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;
}

相关文章