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

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

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

XMLGregorianCalendar.setSecond介绍

[英]Set seconds.

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: robovm/robovm

/**
 * <p>Set time as one unit, including the optional infinite precision
 * fractional seconds.</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 fractional value of <code>null</code> 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,
  BigDecimal fractional) {
  setHour(hour);
  setMinute(minute);
  setSecond(second);
  setFractionalSecond(fractional);
}

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

@Override
public void setSecond(int second)
{
 xmlGregorianCalendar.setSecond(second);
}

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

@Override
public void setSecond(int second)
{
 xmlGregorianCalendar.setSecond(second);
}

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

public void setSecond( int second ) {
  calendar.setSecond( second );
}

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

public void setSecond( int second ) {
  calendar.setSecond( second );
}

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

public void setSecond(Calendar source, XMLGregorianCalendar target) {
  target.setSecond(source.get(Calendar.SECOND));
}

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

public void setSecond(Calendar source, XMLGregorianCalendar target) {
  target.setSecond(source.get(Calendar.SECOND));
}

代码示例来源:origin: matsim-org/matsim

private XMLGregorianCalendar getXmlGregorianCalendar(double seconds) throws DatatypeConfigurationException {
  XMLGregorianCalendar time = DatatypeFactory.newInstance().newXMLGregorianCalendar();
  int s = (int) seconds;
  int h = (s / 3600);
  s = s % 3600;
  int m = (s / 60);
  s = s % 60;
  time.setSecond(s);
  time.setMinute(m);
  time.setHour(h);
  return time;
}

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

GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(System.currentTimeMillis());

try {
  XMLGregorianCalendar xmlGrogerianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
  xmlGrogerianCalendar.setYear(gregorianCalendar.get(GregorianCalendar.YEAR));
  xmlGrogerianCalendar.setMonth(gregorianCalendar.get(GregorianCalendar.MONTH));
  xmlGrogerianCalendar.setDay(gregorianCalendar.get(GregorianCalendar.DAY_OF_MONTH));
  xmlGrogerianCalendar.setHour(gregorianCalendar.get(GregorianCalendar.HOUR_OF_DAY));
  xmlGrogerianCalendar.setMinute(gregorianCalendar.get(GregorianCalendar.MINUTE));
  xmlGrogerianCalendar.setSecond(gregorianCalendar.get(GregorianCalendar.SECOND));

  System.out.println(xmlGrogerianCalendar.toXMLFormat() );

} catch (DatatypeConfigurationException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}

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

private String stringFromSQLTime(Time sourceTime) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  Calendar cal = Calendar.getInstance(getTimeZone());
  cal.setTime(sourceTime);
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  string = appendMillis(string, sourceTime.getTime());
  return appendTimeZone(string, sourceTime);
}

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

private String stringFromSQLTime(Time sourceTime) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceTime);
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  string = appendMillis(string, sourceTime.getTime());
  return appendTimeZone(string, sourceTime);
}

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

private String stringFromSQLTime(Time sourceTime) {
  XMLGregorianCalendar xgc = getDatatypeFactory().newXMLGregorianCalendar();
  GregorianCalendar cal = new GregorianCalendar(getTimeZone());
  cal.setGregorianChange(new Date(Long.MIN_VALUE));
  cal.setTime(sourceTime);
  xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
  xgc.setMinute(cal.get(Calendar.MINUTE));
  xgc.setSecond(cal.get(Calendar.SECOND));
  String string= xgc.toXMLFormat();
  return appendTimeZone(string);
}

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

private XMLGregorianCalendar midnightIfDate(XMLGregorianCalendar clone) {
  if (clone == null) {
    return null;
  }
  if (clone.getHour() == DatatypeConstants.FIELD_UNDEFINED) {
    clone.setHour(0);
    clone.setMinute(0);
    clone.setSecond(0);
  }
  return clone;
}

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

private XMLGregorianCalendar midnightIfDate(XMLGregorianCalendar clone) {
  if (clone == null) {
    return null;
  }
  if (clone.getHour() == DatatypeConstants.FIELD_UNDEFINED) {
    clone.setHour(0);
    clone.setMinute(0);
    clone.setSecond(0);
  }
  return clone;
}

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

相关文章