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

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

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

XMLGregorianCalendar.getTimezone介绍

[英]Return timezone offset in minutes or DatatypeConstants#FIELD_UNDEFINED if this optional field is not defined.

Value constraints for this value are summarized in timezone field of date/time field mapping table.
[中]返回时区偏移量(以分钟为单位),如果未定义此可选字段,则返回DatatypeConstants#字段_未定义。
此值的值约束汇总在timezone field of date/time field mapping table中。

代码示例

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

int offset = value.getTimezone();
    if(offset == 0) {
  buf.append('Z');

代码示例来源: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: opentripplanner/OpenTripPlanner

XMLGregorianCalendar xmlGregCal = df.newXMLGregorianCalendar(time);
GregorianCalendar gregCal = xmlGregCal.toGregorianCalendar();
if (xmlGregCal.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
  gregCal.setTimeZone(tz);

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

int offset = value.getTimezone();
    if(offset == 0) {
  buf.append('Z');

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

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

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

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

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

public Duration timezone(XMLGregorianCalendar date) {
  // timezone offset in seconds
  int secondsOffset = date.getTimezone();
  return DATA_TYPE_FACTORY.newDuration(secondsOffset * 1000);
}

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

public Duration timezone(XMLGregorianCalendar date) {
  // timezone offset in seconds
  int secondsOffset = date.getTimezone();
  return DATA_TYPE_FACTORY.newDuration(secondsOffset * 1000);
}

代码示例来源:origin: org.evolvis.bsi/kolab-ws-service-stub

public static Date
parseDateTime(String s)
{
  if (s == null)
    return null;
  s = s.trim();
  XMLGregorianCalendar gcal = DATATYPE_FACTORY.newXMLGregorianCalendar(s);
  if (DatatypeConstants.FIELD_UNDEFINED == gcal.getTimezone())
    gcal.setTimezone(0);
  GregorianCalendar gc = gcal.toGregorianCalendar();
  return gc.getTime();
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

private String stringFromXMLGregorianCalendar(XMLGregorianCalendar cal, QName schemaTypeQName) {
  if(schemaTypeQName !=null && schemaTypeQName.equals(cal.getXMLSchemaType()) && schemaTypeQName != Constants.G_MONTH_QNAME){
   return cal.toXMLFormat();
  }
  GregorianCalendar gCal = cal.toGregorianCalendar();
  if(cal.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
    gCal.clear(Calendar.ZONE_OFFSET);
  }
  return  stringFromCalendar(gCal, schemaTypeQName);
}

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

private String stringFromXMLGregorianCalendar(XMLGregorianCalendar cal, QName schemaTypeQName) {
  if(schemaTypeQName !=null && schemaTypeQName.equals(cal.getXMLSchemaType()) && schemaTypeQName != Constants.G_MONTH_QNAME){
   return cal.toXMLFormat();
  }
  GregorianCalendar gCal = cal.toGregorianCalendar();
  if(cal.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
    gCal.clear(Calendar.ZONE_OFFSET);
  }        
  return  stringFromCalendar(gCal, schemaTypeQName);
}

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

private XMLGregorianCalendar normalize(XMLGregorianCalendar first) {
  XMLGregorianCalendar normal1 = (XMLGregorianCalendar) first.clone();
  if (first.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
    normal1 = normalizeToTimezone(first, 0);
  }
  return normal1.normalize();
}

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

private XMLGregorianCalendar normalize(XMLGregorianCalendar first) {
  XMLGregorianCalendar normal1 = (XMLGregorianCalendar) first.clone();
  if (first.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
    normal1 = normalizeToTimezone(first, 0);
  }
  return normal1.normalize();
}

代码示例来源:origin: net.sourceforge.owlapi/pellet-core-ignazio1977

@Override
public XMLGregorianCalendar getValue(ATermAppl literal) throws InvalidLiteralException {
  final XMLGregorianCalendar c = super.getValue( literal );
  if( c.getTimezone() == DatatypeConstants.FIELD_UNDEFINED )
    throw new InvalidLiteralException( getName(), ATermUtils.getLiteralValue( literal ) );
  return c;
}

代码示例来源:origin: com.github.ansell.pellet/pellet-common

@Override
public XMLGregorianCalendar getValue(ATermAppl literal) throws InvalidLiteralException {
  final XMLGregorianCalendar c = super.getValue( literal );
  if( c.getTimezone() == DatatypeConstants.FIELD_UNDEFINED )
    throw new InvalidLiteralException( getName(), ATermUtils.getLiteralValue( literal ) );
  return c;
}

代码示例来源:origin: Galigator/openllet

@Override
public XMLGregorianCalendar getValue(final ATermAppl literal) throws InvalidLiteralException
{
  final XMLGregorianCalendar c = super.getValue(literal);
  if (c.getTimezone() == DatatypeConstants.FIELD_UNDEFINED)
    throw new InvalidLiteralException(getName(), ATermUtils.getLiteralValue(literal));
  return c;
}

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

相关文章