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

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

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

XMLGregorianCalendar.setTimezone介绍

[英]Set the number of minutes in the timezone offset.

Unset this field by invoking the setter with a parameter value of DatatypeConstants#FIELD_UNDEFINED.
[中]设置时区偏移的分钟数。
通过调用参数值为DatatypeConstants#field_UNDEFINED的setter来取消设置此字段。

代码示例

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

@Override
public void setTimezone(int offset)
{
 xmlGregorianCalendar.setTimezone(offset);
}

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

@Override
public void setTimezone(int offset)
{
 xmlGregorianCalendar.setTimezone(offset);
}

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

private XMLGregorianCalendar dateWithoutTimezone(Date date) throws DatatypeConfigurationException {
  calendar.setTime(date);
  XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
  xmlGregorianCalendar.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  return xmlGregorianCalendar;
}

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

XMLGregorianCalendar xmlGrogerianCalendar =
 DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
xmlGrogerianCalendar.setTimezone( DatatypeConstants.FIELD_UNDEFINED );
return xmlGrogerianCalendar;

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

public class XmlDateAdapter extends XmlAdapter<XMLGregorianCalendar, Date> {

@Override
public XMLGregorianCalendar marshal(Date date) throws Exception {
  GregorianCalendar gcal = new GregorianCalendar();
  gcal.setTime(date);
  XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
  xmlDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  return xmlDate;
}
// ...

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

public static Date parseLexicalForm(String date) {
   XMLGregorianCalendar xgc = factory.newXMLGregorianCalendar(date);
   int offset = TimeZone.getDefault().getOffset(xgc.toGregorianCalendar().getTimeInMillis());
   xgc.setTimezone(offset / 60000);
   GregorianCalendar gc = new GregorianCalendar(0, 0, 0);
   gc.setTime(xgc.toGregorianCalendar().getTime());
   gc.set(GregorianCalendar.DATE, xgc.getDay());
   return gc.getTime();
 }
}

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

public static Date
parseDate(String s)
{
  if (s == null)
    return null;
  XMLGregorianCalendar gcal = DATATYPE_FACTORY.newXMLGregorianCalendar(s);
  gcal.setTimezone(0);
  GregorianCalendar gc = gcal.toGregorianCalendar();
  return checkDate(gc.getTime());
}

代码示例来源: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: stackoverflow.com

GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(c.getTimeInMillis());

XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
calendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
calendar.setTimezone(DatatypeConstants.FIELD_UNDEFINED);

代码示例来源:origin: jasperkrijgsman/dutch-sepa-iso20022

public static XMLGregorianCalendar createXMLGregorianCalendar(Date currentDateTime) {
  GregorianCalendar calendar = new GregorianCalendar();
  calendar.setTime(currentDateTime);
  XMLGregorianCalendar createDate;
  try {
    createDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
    createDate.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
    createDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  } catch (DatatypeConfigurationException e) {
    throw new RuntimeException(e);
  }
  return createDate;
}

代码示例来源:origin: jasperkrijgsman/dutch-sepa-iso20022

public static XMLGregorianCalendar createXMLGregorianCalendar(Date currentDateTime) {
  GregorianCalendar calendar = new GregorianCalendar();
  calendar.setTime(currentDateTime);
  XMLGregorianCalendar createDate;
  try {
    createDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
    createDate.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
    createDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  } catch (DatatypeConfigurationException e) {
    throw new RuntimeException(e);
  }
  return createDate;
}

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

private XMLGregorianCalendar normalizeToTimezone(int timezone) {
  int seconds = timezone;
  XMLGregorianCalendar result = (XMLGregorianCalendar) this.clone();
  // normalizing to UTC time negates the timezone offset before addition.
  seconds = - seconds;
  Duration d = DefaultFEELLib.DATA_TYPE_FACTORY.newDuration(seconds >= 0, 0, 0, 0, 0, 0, seconds < 0 ? - seconds : seconds);
  result.add(d);
  // set to zulu UTC time.
  result.setTimezone(0);
  return result;
}

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

private XMLGregorianCalendar normalizeToTimezone(int timezone) {
  int seconds = timezone;
  XMLGregorianCalendar result = (XMLGregorianCalendar) this.clone();
  // normalizing to UTC time negates the timezone offset before addition.
  seconds = - seconds;
  Duration d = DefaultFEELLib.DATA_TYPE_FACTORY.newDuration(seconds >= 0, 0, 0, 0, 0, 0, seconds < 0 ? - seconds : seconds);
  result.add(d);
  // set to zulu UTC time.
  result.setTimezone(0);
  return result;
}

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

public static XMLGregorianCalendar convertToXMLGregorianCalendarNoTimeZoneNoMillis(Date date) {
  XMLGregorianCalendar basicCalender = convertToXMLGregorianCalendar(date);
  basicCalender.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  basicCalender.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
  return basicCalender;
}

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

public static XMLGregorianCalendar convertToXMLGregorianCalendarNoTimeZoneNoMillis(Date date) {
  XMLGregorianCalendar basicCalender = convertToXMLGregorianCalendar(date);
  basicCalender.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  basicCalender.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
  return basicCalender;
}

代码示例来源:origin: org.dd4t/dd4t-mvc-support

public String getXMLDateAsString(DateTime date) {
  try {
    GregorianCalendar c = date.toGregorianCalendar();
    XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    xmlDate.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
    xmlDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
    return xmlDate.toXMLFormat();
  } catch (DatatypeConfigurationException e) {
    LOG.error(e.getLocalizedMessage(), e);
  }
  return "";
}

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

@Override
public XMLGregorianCalendar date(XMLGregorianCalendar from) {
  if (from == null) {
    return null;
  }
  XMLGregorianCalendar clone = (XMLGregorianCalendar) from.clone();
  clone.setTime(DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);
  clone.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  return DateTimeUtil.isValidDate(clone) ? clone : null;
}

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

@Override
public XMLGregorianCalendar date(XMLGregorianCalendar from) {
  if (from == null) {
    return null;
  }
  XMLGregorianCalendar clone = (XMLGregorianCalendar) from.clone();
  clone.setTime(DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);
  clone.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  return DateTimeUtil.isValidDate(clone) ? clone : null;
}

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

@Override
public XMLGregorianCalendar normalize() {
  XMLGregorianCalendar normalized = normalizeToTimezone(timezone);
  // if timezone was undefined, leave it undefined
  if (getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
    normalized.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  }
  // if milliseconds was undefined, leave it undefined
  if (getMillisecond() == DatatypeConstants.FIELD_UNDEFINED) {
    normalized.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
  }
  return normalized;
}

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

@Override
public XMLGregorianCalendar normalize() {
  XMLGregorianCalendar normalized = normalizeToTimezone(timezone);
  // if timezone was undefined, leave it undefined
  if (getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
    normalized.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
  }
  // if milliseconds was undefined, leave it undefined
  if (getMillisecond() == DatatypeConstants.FIELD_UNDEFINED) {
    normalized.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
  }
  return normalized;
}

相关文章