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

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

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

XMLGregorianCalendar.toGregorianCalendar介绍

[英]Convert this XMLGregorianCalendar to a GregorianCalendar.

When this instance has an undefined field, this conversion relies on the java.util.GregorianCalendar default for its corresponding field. A notable difference between XML Schema 1.0 date/time datatypes and java.util.GregorianCalendar is that Timezone value is optional for date/time datatypes and it is a required field for java.util.GregorianCalendar. See javadoc for java.util.TimeZone.getDefault() on how the default is determined. To explicitly specify the TimeZone instance, see #toGregorianCalendar(TimeZone,Locale,XMLGregorianCalendar).
Field by Field Conversion from this class to java.util.GregorianCalendar``java.util.GregorianCalendar fieldjavax.xml.datatype.XMLGregorianCalendar fieldERA#getEonAndYear().signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD``YEAR#getEonAndYear().abs().intValue()MONTH#getMonth() - DatatypeConstants#JANUARY + GregorianCalendar#JANUARYDAY_OF_MONTH#getDay()HOUR_OF_DAY#getHour()MINUTE#getMinute()SECOND#getSecond()MILLISECONDget millisecond order from #getFractionalSecond()GregorianCalendar.setTimeZone(TimeZone)#getTimezone() formatted into Custom timezone id* designates possible loss of precision during the conversion due to source datatype having higher precision than target datatype.

To ensure consistency in conversion implementations, the new GregorianCalendar should be instantiated in following manner.

  • Using timeZone value as defined above, create a new java.util.GregorianCalendar(timeZone,Locale.getDefault()).
  • Initialize all GregorianCalendar fields by calling {(@link GegorianCalendar#clear()}.
  • Obtain a pure Gregorian Calendar by invoking GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE)).
  • Its fields ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND and MILLISECOND are set using the method Calendar.set(int,int)
    [中]将此XMLGregorianCalendar转换为GregoriaCalendar。
    this实例有未定义的字段时,此转换依赖于其相应字段的java.util.GregorianCalendar默认值。XML Schema 1.0日期/时间数据类型和java.util.GregorianCalendar之间的一个显著区别是,对于日期/时间数据类型,时区值是可选的,对于[$4$]来说,它是必填字段。有关如何确定默认值,请参见javadoc的java.util.TimeZone.getDefault()。要明确指定TimeZone实例,请参阅#toGregorianCalendar(时区、区域设置、XMLGregorianCalendar)。
    从这一类到[[7美元(7美元[8美元[8美元[8美元[9美元[9美元[9美元[9美元[9美元[9美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元(10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[10美元[#GetFractilSecond()GregorianCalendar.setTimeZone(TimeZone)#getTimezone()格式化为自定义时区id表示由于源数据类型的精度高于目标数据类型,在转换过程中可能会丢失精度。
    为了确保转换实现的一致性,新的GregorianCalendar应该以以下方式实例化。
    *使用上面定义的timeZone值,创建一个新的java.util.GregorianCalendar(timeZone,Locale.getDefault())
    *通过调用{(@link gegorianalendar#clear()}初始化所有Gregorianalendar字段。
    *通过调用GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE))获得一个纯公历。
    *其字段ERA、YEAR、MONTH、DAY_OF_MONTH、HOUR_OF_DAY、MINUTE、SECOND和millis秒使用[$25$]方法设置

代码示例

代码示例来源:origin: prestodb/presto

protected Calendar _convert(XMLGregorianCalendar input) {
    return (input == null) ? null : input.toGregorianCalendar();
  }
}

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

protected Calendar _convert(XMLGregorianCalendar input) {
    return (input == null) ? null : input.toGregorianCalendar();
  }
}

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

protected Calendar _convert(XMLGregorianCalendar input) {
    return (input == null) ? null : input.toGregorianCalendar();
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

public Calendar parseDate(String lexicalXSDDate) {
  return datatypeFactory.newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar();
}

代码示例来源:origin: javax.xml.bind/jaxb-api

public Calendar parseTime(String lexicalXSDTime) {
  return datatypeFactory.newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar();
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public void serialize(XMLGregorianCalendar value, JsonGenerator jgen, SerializerProvider provider)
    throws IOException, JsonGenerationException {
  CalendarSerializer.instance.serialize(value.toGregorianCalendar(), jgen, provider);
}

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

javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar("2011-01-01Z").toGregorianCalendar().getTime()

代码示例来源:origin: citerus/dddsample-core

public static Date parseCompletionTime(HandlingReport handlingReport, List<String> errors) {
  final XMLGregorianCalendar completionTime = handlingReport.getCompletionTime();
  if (completionTime == null) {
   errors.add("Completion time is required");
   return null;
  }

  return completionTime.toGregorianCalendar().getTime();
 }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

public static GregorianCalendar _parseDateTime(CharSequence s) {
  String val = WhiteSpaceProcessor.trim(s).toString();
  return datatypeFactory.newXMLGregorianCalendar(val).toGregorianCalendar();
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

public IsoTimeParameter (String param) {
  // WMS spec annex D: time is specified in ISO8601:2000 extended
  // http://stackoverflow.com/questions/2201925/converting-iso8601-compliant-string-to-java-util-date
  try {
    cal = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(param).toGregorianCalendar();
  } catch (Exception e) {
    throw new WebApplicationException(fail(param, e));
  }
}

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

@Deprecated
public Calendar parseDate(String lexicalXSDDate) {
  return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar();
}

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

@Deprecated
public Calendar parseTime(String lexicalXSDTime) {
  return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar();
}

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

public static GregorianCalendar _parseDateTime(CharSequence s) {
  String val = WhiteSpaceProcessor.trim(s).toString();
  return getDatatypeFactory().newXMLGregorianCalendar(val).toGregorianCalendar();
}

代码示例来源:origin: DozerMapper/dozer

result.setTimeZone(c.getTimeZone());
} else if (XMLGregorianCalendar.class.isAssignableFrom(srcFieldClass)) {
  Calendar c = ((XMLGregorianCalendar)srcObj).toGregorianCalendar();
  result.setTime(c.getTime());
  result.setTimeZone(c.getTimeZone());

代码示例来源:origin: DozerMapper/dozer

result.setTimeZone(c.getTimeZone());
} else if (XMLGregorianCalendar.class.isAssignableFrom(sourceClass)) {
  result = XMLGregorianCalendar.class.cast(srcObj).toGregorianCalendar();
} else if (dateFormat != null && String.class.isAssignableFrom(sourceClass)) {
  if ("".equals(String.class.cast(srcObj))) {

代码示例来源:origin: DozerMapper/dozer

time = ((java.util.Date)srcObj).getTime();
} else if (XMLGregorianCalendar.class.isAssignableFrom(srcFieldClass)) {
  time = ((XMLGregorianCalendar)srcObj).toGregorianCalendar().getTimeInMillis();
} else if (dateFormat != null && String.class.isAssignableFrom(srcObj.getClass())) {
  try {

代码示例来源:origin: alibaba/fastjson

calendar = ((XMLGregorianCalendar) object).toGregorianCalendar();
} else {
  calendar = (Calendar) object;

代码示例来源:origin: com.alibaba/fastjson

calendar = ((XMLGregorianCalendar) object).toGregorianCalendar();
} else {
  calendar = (Calendar) object;

代码示例来源:origin: opentripplanner/OpenTripPlanner

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

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public void serialize(XMLGregorianCalendar value, JsonGenerator jgen, SerializerProvider provider)
    throws IOException, JsonGenerationException {
  CalendarSerializer.instance.serialize(value.toGregorianCalendar(), jgen, provider);
}

相关文章