本文整理了Java中org.apache.xmlbeans.XmlCalendar
类的一些代码示例,展示了XmlCalendar
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlCalendar
类的具体详情如下:
包路径:org.apache.xmlbeans.XmlCalendar
类名称:XmlCalendar
[英]An XML Schema compatible subclass of java.util.GregorianCalendar. XmlCalendar modifies several key details in the behavior of GregorianCalendar to make it more useful when dealing with XML dates.
It is easy to convert between XmlCalendar and GDate, or to parse or emit an XmlCalendar using a standard XML Schema lexical representation.
For example, the XML timezone "Z" is translated to "GMT"; the XML timezone "+05:00" is translated to "GMT+05:00".
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
/**
* Retrieves the value of the current time as an {@link XmlCalendar}.
* <p>
* {@link XmlCalendar} is a subclass of {@link java.util.GregorianCalendar}
* which is slightly customized to match XML schema date rules.
* <p>
* The returned {@link XmlCalendar} has only those time and date fields
* set that are reflected in the GDate object. Because of the way the
* {@link java.util.Calendar} contract works, any information in the isSet() vanishes
* as soon as you view any unset field using get() methods.
* This means that if it is important to understand which date fields
* are set, you must call isSet() first before get().
*/
public XmlCalendar getCalendar()
{
return new XmlCalendar(this);
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
/**
* Overrides GregorianCalendar.computeTime to apply a different
* default year. (It must be a leap year.)
*/
protected void computeTime()
{
boolean unsetYear = !isSet(YEAR);
if (unsetYear)
set(YEAR, getDefaultYear());
try
{
super.computeTime();
}
finally
{
if (unsetYear)
clear(YEAR);
}
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
/**
* Constructs an XmlCalendar from a Date.
*
* The default TimeZone is used for computing the various fields.
*/
public XmlCalendar(Date date)
{
this(TimeZone.getDefault(), new GDate(date));
complete();
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
/**
* Constructs an empty instance with no fields set.
*/
public XmlCalendar()
{
setGregorianChange(_beginningOfTime); // proleptic
clear();
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
/**
* Gets the value for a given time field.
*
* Unlike the GregorianCalendar implementation, the get() does not
* force a complete of all fields. If you wish to force a completion
* of all the fields, call getTime() first.
*/
public int get(int field)
{
if (!isSet(field) || isTimeSet)
return super.get(field); // forces a complete
else
return internalGet(field); // does not force a complete.
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
private XmlCalendar(TimeZone tz, GDateSpecification date)
setGregorianChange(_beginningOfTime); // proleptic
clear();
if (y > 0)
set(Calendar.ERA, GregorianCalendar.AD);
set(Calendar.ERA, GregorianCalendar.BC);
set(Calendar.YEAR, y);
set(Calendar.MONTH, date.getMonth() - 1); // note!!
if (date.hasDay())
set(Calendar.DAY_OF_MONTH, date.getDay());
if (date.hasTime())
set(Calendar.HOUR_OF_DAY, date.getHour());
set(Calendar.MINUTE, date.getMinute());
set(Calendar.SECOND, date.getSecond());
if (date.getFraction().scale() > 0)
set(Calendar.MILLISECOND, date.getMillisecond());
set(Calendar.ZONE_OFFSET, date.getTimeZoneSign() * 1000 * 60 * (date.getTimeZoneHour() * 60 + date.getTimeZoneMinute()));
set(Calendar.DST_OFFSET, 0); // note!! if we don't do this, then GregorianCalendar will pick up DST from the time zone
代码示例来源:origin: com.att.ajsc/ajsc-core
public static String getStartTimestamp(String epoch) {
long stime = Long.parseLong((String) epoch);
XmlCalendar cal = new XmlCalendar(new Date(stime));
XMLGregorianCalendar initTime = null;
try {
initTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(
cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
cal.get(Calendar.SECOND), cal.get(Calendar.MILLISECOND),
Math.round(cal.get(Calendar.ZONE_OFFSET) / 1000 / 60));
} catch (Exception ex) {
initTime = null;
}
if (initTime == null)
return null;
else
return initTime.toString();
}
代码示例来源:origin: org.apache.airavata/airavata-workflow-tracking
public static Date getActivityTimestamp(XmlObject activity) throws ParseException {
// $ACTIVITY_XML/*/timestamp
XmlCursor xc = activity.newCursor();
// ./
// xc.toStartDoc();
// ./*
xc.toNextToken();
// ./*/timestamp
xc.toChild(TIMESTAMP_QNAME);
System.out.println(xc.xmlText());
XmlCalendar calendar = new XmlCalendar(xc.getTextValue());
// return getDateFormat().parse(xc.getTextValue()); // fixme: this
// supports only one date format
return calendar.getTime();
}
代码示例来源:origin: org.apache.xmlbeans/com.springsource.org.apache.xmlbeans
private XmlCalendar(TimeZone tz, GDateSpecification date)
setGregorianChange(_beginningOfTime); // proleptic
clear();
if (y > 0)
set(Calendar.ERA, GregorianCalendar.AD);
set(Calendar.ERA, GregorianCalendar.BC);
set(Calendar.YEAR, y);
set(Calendar.MONTH, date.getMonth() - 1); // note!!
if (date.hasDay())
set(Calendar.DAY_OF_MONTH, date.getDay());
if (date.hasTime())
set(Calendar.HOUR_OF_DAY, date.getHour());
set(Calendar.MINUTE, date.getMinute());
set(Calendar.SECOND, date.getSecond());
if (date.getFraction().scale() > 0)
set(Calendar.MILLISECOND, date.getMillisecond());
set(Calendar.ZONE_OFFSET, date.getTimeZoneSign() * 1000 * 60 * (date.getTimeZoneHour() * 60 + date.getTimeZoneMinute()));
set(Calendar.DST_OFFSET, 0); // note!! if we don't do this, then GregorianCalendar will pick up DST from the time zone
代码示例来源:origin: org.apache.xmlbeans/com.springsource.org.apache.xmlbeans
/**
* Constructs an empty instance with no fields set.
*/
public XmlCalendar()
{
setGregorianChange(_beginningOfTime); // proleptic
clear();
}
代码示例来源:origin: org.apache.xmlbeans/com.springsource.org.apache.xmlbeans
/**
* Gets the value for a given time field.
*
* Unlike the GregorianCalendar implementation, the get() does not
* force a complete of all fields. If you wish to force a completion
* of all the fields, call getTime() first.
*/
public int get(int field)
{
if (!isSet(field) || isTimeSet)
return super.get(field); // forces a complete
else
return internalGet(field); // does not force a complete.
}
代码示例来源:origin: org.apache.xmlbeans/com.springsource.org.apache.xmlbeans
/**
* Overrides GregorianCalendar.computeTime to apply a different
* default year. (It must be a leap year.)
*/
protected void computeTime()
{
boolean unsetYear = !isSet(YEAR);
if (unsetYear)
set(YEAR, getDefaultYear());
try
{
super.computeTime();
}
finally
{
if (unsetYear)
clear(YEAR);
}
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
/**
* Retrieves the value of the current time as an {@link XmlCalendar}.
* <p>
* {@link XmlCalendar} is a subclass of {@link java.util.GregorianCalendar}
* which is slightly customized to match XML schema date rules.
* <p>
* The returned {@link XmlCalendar} has only those time and date fields
* set that are reflected in the GDate object. Because of the way the
* {@link java.util.Calendar} contract works, any information in the isSet() vanishes
* as soon as you view any unset field using get() methods.
* This means that if it is important to understand which date fields
* are set, you must call isSet() first before get().
*/
public XmlCalendar getCalendar()
{
return new XmlCalendar(this);
}
代码示例来源:origin: com.github.pjfanning/xmlbeans
private XmlCalendar(TimeZone tz, GDateSpecification date)
setGregorianChange(_beginningOfTime); // proleptic
clear();
if (y > 0)
set(Calendar.ERA, GregorianCalendar.AD);
set(Calendar.ERA, GregorianCalendar.BC);
set(Calendar.YEAR, y);
set(Calendar.MONTH, date.getMonth() - 1); // note!!
if (date.hasDay())
set(Calendar.DAY_OF_MONTH, date.getDay());
if (date.hasTime())
set(Calendar.HOUR_OF_DAY, date.getHour());
set(Calendar.MINUTE, date.getMinute());
set(Calendar.SECOND, date.getSecond());
if (date.getFraction().scale() > 0)
set(Calendar.MILLISECOND, date.getMillisecond());
set(Calendar.ZONE_OFFSET, date.getTimeZoneSign() * 1000 * 60 * (date.getTimeZoneHour() * 60 + date.getTimeZoneMinute()));
set(Calendar.DST_OFFSET, 0); // note!! if we don't do this, then GregorianCalendar will pick up DST from the time zone
代码示例来源:origin: com.github.pjfanning/xmlbeans
/**
* Constructs an empty instance with no fields set.
*/
public XmlCalendar()
{
setGregorianChange(_beginningOfTime); // proleptic
clear();
}
代码示例来源:origin: com.github.pjfanning/xmlbeans
/**
* Gets the value for a given time field.
*
* Unlike the GregorianCalendar implementation, the get() does not
* force a complete of all fields. If you wish to force a completion
* of all the fields, call getTime() first.
*/
public int get(int field)
{
if (!isSet(field) || isTimeSet)
return super.get(field); // forces a complete
else
return internalGet(field); // does not force a complete.
}
代码示例来源:origin: com.github.pjfanning/xmlbeans
/**
* Constructs an XmlCalendar from a Date.
*
* The default TimeZone is used for computing the various fields.
*/
public XmlCalendar(Date date)
{
this(TimeZone.getDefault(), new GDate(date));
complete();
}
代码示例来源:origin: com.github.pjfanning/xmlbeans
/**
* Overrides GregorianCalendar.computeTime to apply a different
* default year. (It must be a leap year.)
*/
protected void computeTime()
{
boolean unsetYear = !isSet(YEAR);
if (unsetYear)
set(YEAR, getDefaultYear());
try
{
super.computeTime();
}
finally
{
if (unsetYear)
clear(YEAR);
}
}
代码示例来源:origin: org.apache.xmlbeans/xmlbeans
writer.println("<p>Run on " + (new XmlCalendar(new Date())) + "</p>");
writer.println("<p>Values in schema or instance valid columns are results from compiling or validating respectively.");
writer.println("Red or orange background mean the test failed.</p>");
代码示例来源:origin: org.apache.xmlbeans/com.springsource.org.apache.xmlbeans
/**
* Constructs an XmlCalendar from a Date.
*
* The default TimeZone is used for computing the various fields.
*/
public XmlCalendar(Date date)
{
this(TimeZone.getDefault(), new GDate(date));
complete();
}
内容来源于网络,如有侵权,请联系作者删除!