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

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

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

XMLGregorianCalendar.setMillisecond介绍

[英]Set milliseconds.

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

代码示例

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

/**
 * <p>Set time as one unit, including optional milliseconds.</p>
 *
 * @param hour value constraints are summarized in
 * <a href="#datetimefield-hour">hour field of date/time field mapping table</a>.
 * @param minute value constraints are summarized in
 * <a href="#datetimefield-minute">minute field of date/time field mapping table</a>.
 * @param second value constraints are summarized in
 * <a href="#datetimefield-second">second field of date/time field mapping table</a>.
 * @param millisecond value of {@link DatatypeConstants#FIELD_UNDEFINED} indicates this
 *                    optional field is not set.
 *
 * @throws IllegalArgumentException if any parameter is
 * outside value constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public void setTime(int hour, int minute, int second, int millisecond) {
  setHour(hour);
  setMinute(minute);
  setSecond(second);
  setMillisecond(millisecond);
}

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

@Override
public void setMillisecond(int millisecond)
{
 xmlGregorianCalendar.setMillisecond(millisecond);
}

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

@Override
public void setMillisecond(int millisecond)
{
 xmlGregorianCalendar.setMillisecond(millisecond);
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-runtime

public void setMillisecond(Calendar source, XMLGregorianCalendar target) {
  final int millisecond = source.get(Calendar.MILLISECOND);
  if (millisecond != 0) {
    target.setMillisecond(millisecond);
  }
}

代码示例来源:origin: highsource/hyperjaxb3

public void setMillisecond(Calendar source, XMLGregorianCalendar target) {
  final int millisecond = source.get(Calendar.MILLISECOND);
  if (millisecond != 0) {
    target.setMillisecond(millisecond);
  }
}

代码示例来源:origin: no.difi.vefa/peppol-evidence

public static XMLGregorianCalendar toXmlGregorianCalendar(Date date) throws RemEvidenceException {
  GregorianCalendar c = new GregorianCalendar();
  c.setTime(date);
  XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(c);
  xmlGregorianCalendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
  return xmlGregorianCalendar;
}

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

GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
XMLGregorianCalendar xmlDate =  DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);   
xmlDate.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);

代码示例来源: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: Samuel-Oliveira/Java_NFe

public static String dataNfe() throws NfeException {
  try {
    LocalDateTime dataASerFormatada = LocalDateTime.now();
    GregorianCalendar calendar = GregorianCalendar.from(dataASerFormatada.atZone(ZoneId.of("Brazil/East")));
    XMLGregorianCalendar xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
    xmlCalendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
    return (xmlCalendar.toString());
  } catch (DatatypeConfigurationException e) {
    throw new NfeException(e.getMessage());
  }
}

代码示例来源: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 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: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-runtime

@SuppressWarnings("deprecation")
  @Override
  public void createCalendar(Date date, XMLGregorianCalendar calendar) {
    calendar.setHour(date.getHours());
    calendar.setMinute(date.getMinutes());
    calendar.setSecond(date.getSeconds());
    calendar.setMillisecond((int) (date.getTime() % 1000));
  }
}

代码示例来源:origin: highsource/hyperjaxb3

@SuppressWarnings("deprecation")
  @Override
  public void createCalendar(Date date, XMLGregorianCalendar calendar) {
    calendar.setHour(date.getHours());
    calendar.setMinute(date.getMinutes());
    calendar.setSecond(date.getSeconds());
    calendar.setMillisecond((int) (date.getTime() % 1000));
  }
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-runtime

@SuppressWarnings("deprecation")
  @Override
  public void createCalendar(Date date, XMLGregorianCalendar calendar) {
    calendar.setYear(date.getYear() + 1900);
    calendar.setMonth(date.getMonth() + 1);
    calendar.setDay(date.getDate());
    calendar.setHour(date.getHours());
    calendar.setMinute(date.getMinutes());
    calendar.setSecond(date.getSeconds());
    calendar.setMillisecond((int) (date.getTime() % 1000));
  }
}

代码示例来源:origin: highsource/hyperjaxb3

@SuppressWarnings("deprecation")
  @Override
  public void createCalendar(Date date, XMLGregorianCalendar calendar) {
    calendar.setYear(date.getYear() + 1900);
    calendar.setMonth(date.getMonth() + 1);
    calendar.setDay(date.getDate());
    calendar.setHour(date.getHours());
    calendar.setMinute(date.getMinutes());
    calendar.setSecond(date.getSeconds());
    calendar.setMillisecond((int) (date.getTime() % 1000));
  }
}

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

protected static XMLGregorianCalendar composeDateTime() throws Exception {
  DateTime dateTime = DateTime.now();
  XMLGregorianCalendar xts = datatypeFactory.newXMLGregorianCalendar();
  xts.setYear(dateTime.getYear());
  xts.setMonth(dateTime.getMonthOfYear());
  xts.setDay(dateTime.getDayOfMonth());
  xts.setHour(dateTime.getHourOfDay());
  xts.setMinute(dateTime.getMinuteOfHour());
  xts.setSecond(dateTime.getSecondOfMinute());
  xts.setMillisecond(dateTime.getMillisOfSecond());
  xts.setTimezone(dateTime.getZone().toTimeZone().getRawOffset() / 60000);
  return xts;
}

相关文章