xmlgregoriancalendarimpl.java
来自「JAVA 所有包」· Java 代码 · 共 1,796 行 · 第 1/5 页
JAVA
1,796 行
* <a href="#datetimefieldmapping">date/time field mapping table</a>. * * @see DatatypeConstants#FIELD_UNDEFINED */ public static XMLGregorianCalendar createDateTime( int year, int month, int day, int hour, int minute, int second) { return new XMLGregorianCalendarImpl( year, month, day, hour, minute, second, DatatypeConstants.FIELD_UNDEFINED, //millisecond DatatypeConstants.FIELD_UNDEFINED //timezone ); } /** * <p>Create a Java representation of XML Schema builtin datatype <code>dateTime</code>. * All possible fields are specified for this factory method.</p> * * @param year represents low-order year. * @param month of <code>dateTime</code> * @param day of <code>dateTime</code> * @param hours of <code>dateTime</code> * @param minutes of <code>dateTime</code> * @param seconds of <code>dateTime</code> * @param milliseconds of <code>dateTime</code>. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. * * @return <code>XMLGregorianCalendar</code> created from parameter values. * * @throws IllegalArgumentException if any parameter is outside value constraints for the field as specified in * <a href="#datetimefieldmapping">date/time field mapping table</a>. * * @see DatatypeConstants#FIELD_UNDEFINED */ public static XMLGregorianCalendar createDateTime( int year, int month, int day, int hours, int minutes, int seconds, int milliseconds, int timezone) { return new XMLGregorianCalendarImpl( year, month, day, hours, minutes, seconds, milliseconds, timezone); } /** * <p>Create a Java representation of XML Schema builtin datatype <code>date</code> or <code>g*</code>.</p> * * <p>For example, an instance of <code>gYear</code> can be created invoking this factory * with <code>month</code> and <code>day</code> parameters set to * {@link DatatypeConstants#FIELD_UNDEFINED}.</p> * * @param year of <code>XMLGregorianCalendar</code> to be created. * @param month of <code>XMLGregorianCalendar</code> to be created. * @param day of <code>XMLGregorianCalendar</code> to be created. * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. * * @return <code>XMLGregorianCalendar</code> created from parameter values. * * @see DatatypeConstants#FIELD_UNDEFINED * * @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 static XMLGregorianCalendar createDate( int year, int month, int day, int timezone) { return new XMLGregorianCalendarImpl( year, month, day, DatatypeConstants.FIELD_UNDEFINED, // hour DatatypeConstants.FIELD_UNDEFINED, // minute DatatypeConstants.FIELD_UNDEFINED, // second DatatypeConstants.FIELD_UNDEFINED, // millisecond timezone); } /** * Create a Java instance of XML Schema builtin datatype <code>time</code>. * @param hours number of hours * @param minutes number of minutes * @param seconds number of seconds * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. * * @return <code>XMLGregorianCalendar</code> created from parameter values. * * @see DatatypeConstants#FIELD_UNDEFINED * * @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 static XMLGregorianCalendar createTime( int hours, int minutes, int seconds, int timezone) { return new XMLGregorianCalendarImpl( DatatypeConstants.FIELD_UNDEFINED, // Year DatatypeConstants.FIELD_UNDEFINED, // Month DatatypeConstants.FIELD_UNDEFINED, // Day hours, minutes, seconds, DatatypeConstants.FIELD_UNDEFINED, //Millisecond timezone); } /** * <p>Create a Java instance of XML Schema builtin datatype time.</p> * * @param hours number of hours * @param minutes number of minutes * @param seconds number of seconds * @param fractionalSecond value of <code>null</code> indicates that this optional field is not set. * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. * * @return <code>XMLGregorianCalendar</code> created from parameter values. * * @see DatatypeConstants#FIELD_UNDEFINED * * @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 static XMLGregorianCalendar createTime( int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone) { return new XMLGregorianCalendarImpl( null, // Year DatatypeConstants.FIELD_UNDEFINED, // month DatatypeConstants.FIELD_UNDEFINED, // day hours, minutes, seconds, fractionalSecond, timezone); } /** * <p>Create a Java instance of XML Schema builtin datatype time.</p> * * @param hours number of hours * @param minutes number of minutes * @param seconds number of seconds * @param milliseconds number of milliseconds * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. * * @return <code>XMLGregorianCalendar</code> created from parameter values. * * @see DatatypeConstants#FIELD_UNDEFINED * * @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 static XMLGregorianCalendar createTime( int hours, int minutes, int seconds, int milliseconds, int timezone) { return new XMLGregorianCalendarImpl( DatatypeConstants.FIELD_UNDEFINED, // year DatatypeConstants.FIELD_UNDEFINED, // month DatatypeConstants.FIELD_UNDEFINED, // day hours, minutes, seconds, milliseconds, timezone); } // Accessors /** * <p>Return high order component for XML Schema 1.0 dateTime datatype field for * <code>year</code>. * <code>null</code> if this optional part of the year field is not defined.</p> * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-year">year field of date/time field mapping table</a>.</p> * @return eon of this <code>XMLGregorianCalendar</code>. The value * returned is an integer multiple of 10^9. * * @see #getYear() * @see #getEonAndYear() */ public BigInteger getEon() { return eon; } /** * <p>Return low order component for XML Schema 1.0 dateTime datatype field for * <code>year</code> or {@link DatatypeConstants#FIELD_UNDEFINED}.</p> * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-year">year field of date/time field mapping table</a>.</p> * * @return year of this <code>XMLGregorianCalendar</code>. * * @see #getEon() * @see #getEonAndYear() */ public int getYear() { return year; } /** * <p>Return XML Schema 1.0 dateTime datatype field for * <code>year</code>.</p> * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-year">year field of date/time field mapping table</a>.</p> * * @return sum of <code>eon</code> and <code>BigInteger.valueOf(year)</code> * when both fields are defined. When only <code>year</code> is defined, * return it. When both <code>eon</code> and <code>year</code> are not * defined, return <code>null</code>. * * @see #getEon() * @see #getYear() */ public BigInteger getEonAndYear() { // both are defined if (year != DatatypeConstants.FIELD_UNDEFINED && eon != null) { return eon.add(BigInteger.valueOf((long) year)); } // only year is defined if (year != DatatypeConstants.FIELD_UNDEFINED && eon == null) { return BigInteger.valueOf((long) year); } // neither are defined // or only eon is defined which is not valid without a year return null; } /** * <p>Return number of month or {@link DatatypeConstants#FIELD_UNDEFINED}.</p> * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-month">month field of date/time field mapping table</a>.</p> * * @return year of this <code>XMLGregorianCalendar</code>. * */ public int getMonth() { return month; } /** * Return day in month or {@link DatatypeConstants#FIELD_UNDEFINED}.</p> * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-day">day field of date/time field mapping table</a>.</p> * * @see #setDay(int) */ public int getDay() { return day; } /** * Return timezone offset in minutes or * {@link DatatypeConstants#FIELD_UNDEFINED} if this optional field is not defined. * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-timezone">timezone field of date/time field mapping table</a>.</p> * * @see #setTimezone(int) */ public int getTimezone() { return timezone; } /** * Return hours or {@link DatatypeConstants#FIELD_UNDEFINED}. * Returns {@link DatatypeConstants#FIELD_UNDEFINED} if this field is not defined. * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-hour">hour field of date/time field mapping table</a>.</p> * @see #setTime(int, int, int) */ public int getHour() { return hour; } /** * Return minutes or {@link DatatypeConstants#FIELD_UNDEFINED}.<\p> * Returns {@link DatatypeConstants#FIELD_UNDEFINED} if this field is not defined. * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-minute">minute field of date/time field mapping table</a>.</p> * @see #setTime(int, int, int) */ public int getMinute() { return minute; } /** * <p>Return seconds or {@link DatatypeConstants#FIELD_UNDEFINED}.<\p> * * <p>Returns {@link DatatypeConstants#FIELD_UNDEFINED} if this field is not defined. * When this field is not defined, the optional xs:dateTime * fractional seconds field, represented by * {@link #getFractionalSecond()} and {@link #getMillisecond()}, * must not be defined.</p> * * <p>Value constraints for this value are summarized in * <a href="#datetimefield-second">second field of date/time field mapping table</a>.</p> * * @return Second of this <code>XMLGregorianCalendar</code>. * * @see #getFractionalSecond() * @see #getMillisecond() * @see #setTime(int, int, int) */ public int getSecond() { return second; } /**
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?