Java Code Examples for javax.xml.datatype.XMLGregorianCalendar#getHour()
The following examples show how to use
javax.xml.datatype.XMLGregorianCalendar#getHour() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLGregorianCalendarImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * <p>Returns a hash code consistent with the definition of the equals method.</p> * * @return hash code of this object. */ public int hashCode() { // Following two dates compare to EQUALS since in different timezones. // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00 // // Must ensure both instances generate same hashcode by normalizing // this to UTC timezone. int timezone = getTimezone(); if (timezone == DatatypeConstants.FIELD_UNDEFINED) { timezone = 0; } XMLGregorianCalendar gc = this; if (timezone != 0) { gc = this.normalizeToTimezone(getTimezone()); } return gc.getYear() + gc.getMonth() + gc.getDay() + gc.getHour() + gc.getMinute() + gc.getSecond(); }
Example 2
Source File: FEELXMLGregorianCalendar.java From jdmn with Apache License 2.0 | 6 votes |
@Override public int hashCode() { // Following two dates compare to EQUALS since in different timezones. // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00 // // Must ensure both instances generate same hashcode by normalizing this to UTC timezone. int timezone = getTimezone(); if (timezone == DatatypeConstants.FIELD_UNDEFINED) { timezone = 0; } XMLGregorianCalendar gc = this; if (timezone != 0) { gc = this.normalizeToTimezone(getZoneID()); } return gc.getYear() + gc.getMonth() + gc.getDay() + gc.getHour() + gc.getMinute() + gc.getSecond(); }
Example 3
Source File: DateTimeConverter.java From atdl4j with MIT License | 6 votes |
public static DateTime convertXMLGregorianCalendarToDateTime( XMLGregorianCalendar aXMLGregorianCalendar, Timezone aTimezone ) { // -- DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) -- int tempSubsecond = 0; if ( aXMLGregorianCalendar.getFractionalSecond() != null ) { tempSubsecond = aXMLGregorianCalendar.getFractionalSecond().intValue(); } DateTimeZone tempDateTimeZone = convertTimezoneToDateTimeZone( aTimezone ); if ( tempDateTimeZone == null ) { tempDateTimeZone = DateTimeZone.getDefault(); } return new DateTime( aXMLGregorianCalendar.getYear(), aXMLGregorianCalendar.getMonth(), aXMLGregorianCalendar.getDay(), aXMLGregorianCalendar.getHour(), aXMLGregorianCalendar.getMinute(), aXMLGregorianCalendar.getSecond(), tempSubsecond, tempDateTimeZone ); }
Example 4
Source File: XMLGregorianCalendarImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * <p>Returns a hash code consistent with the definition of the equals method.</p> * * @return hash code of this object. */ public int hashCode() { // Following two dates compare to EQUALS since in different timezones. // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00 // // Must ensure both instances generate same hashcode by normalizing // this to UTC timezone. int timezone = getTimezone(); if (timezone == DatatypeConstants.FIELD_UNDEFINED) { timezone = 0; } XMLGregorianCalendar gc = this; if (timezone != 0) { gc = this.normalizeToTimezone(getTimezone()); } return gc.getYear() + gc.getMonth() + gc.getDay() + gc.getHour() + gc.getMinute() + gc.getSecond(); }
Example 5
Source File: XMLGregorianCalendarImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * <p>Returns a hash code consistent with the definition of the equals method.</p> * * @return hash code of this object. */ public int hashCode() { // Following two dates compare to EQUALS since in different timezones. // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00 // // Must ensure both instances generate same hashcode by normalizing // this to UTC timezone. int timezone = getTimezone(); if (timezone == DatatypeConstants.FIELD_UNDEFINED) { timezone = 0; } XMLGregorianCalendar gc = this; if (timezone != 0) { gc = this.normalizeToTimezone(getTimezone()); } return gc.getYear() + gc.getMonth() + gc.getDay() + gc.getHour() + gc.getMinute() + gc.getSecond(); }
Example 6
Source File: XMLGregorianCalendarImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * <p>Returns a hash code consistent with the definition of the equals method.</p> * * @return hash code of this object. */ public int hashCode() { // Following two dates compare to EQUALS since in different timezones. // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00 // // Must ensure both instances generate same hashcode by normalizing // this to UTC timezone. int timezone = getTimezone(); if (timezone == DatatypeConstants.FIELD_UNDEFINED) { timezone = 0; } XMLGregorianCalendar gc = this; if (timezone != 0) { gc = this.normalizeToTimezone(getTimezone()); } return gc.getYear() + gc.getMonth() + gc.getDay() + gc.getHour() + gc.getMinute() + gc.getSecond(); }
Example 7
Source File: Hours.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 1) { throw new ValueExprEvaluationException("HOURS requires 1 argument, got " + args.length); } Value argValue = args[0]; if (argValue instanceof Literal) { Literal literal = (Literal) argValue; IRI datatype = literal.getDatatype(); if (datatype != null && XMLDatatypeUtil.isCalendarDatatype(datatype)) { try { XMLGregorianCalendar calValue = literal.calendarValue(); int hours = calValue.getHour(); if (DatatypeConstants.FIELD_UNDEFINED != hours) { return valueFactory.createLiteral(String.valueOf(hours), XMLSchema.INTEGER); } else { throw new ValueExprEvaluationException("can not determine hours from value: " + argValue); } } catch (IllegalArgumentException e) { throw new ValueExprEvaluationException("illegal calendar value: " + argValue); } } else { throw new ValueExprEvaluationException("unexpected input value for function: " + argValue); } } else { throw new ValueExprEvaluationException("unexpected input value for function: " + args[0]); } }
Example 8
Source File: AbstractTypeTestClient.java From cxf with Apache License 2.0 | 5 votes |
protected boolean equalsTime(XMLGregorianCalendar orig, XMLGregorianCalendar actual) { boolean result = false; if ((orig.getHour() == actual.getHour()) && (orig.getMinute() == actual.getMinute()) && (orig.getSecond() == actual.getSecond()) && (orig.getMillisecond() == actual.getMillisecond()) && (orig.getTimezone() == actual.getTimezone())) { result = true; } return result; }
Example 9
Source File: XMLGregorianCalendarTypeInfoProducer.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 5 votes |
@Override public JsonValue createValue(JsonSchemaMappingCompiler<T, C> mappingCompiler, String item) { final JsonObjectBuilder objectBuilder = mappingCompiler.getJsonBuilderFactory().createObjectBuilder(); final XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(item); if (calendar.getYear() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("year", calendar.getYear()); } if (calendar.getMonth() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("month", calendar.getMonth()); } if (calendar.getDay() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("day", calendar.getDay()); } if (calendar.getHour() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("hour", calendar.getHour()); } if (calendar.getMinute() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("minute", calendar.getMinute()); } if (calendar.getSecond() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("second", calendar.getSecond()); } if (calendar.getFractionalSecond() != null) { objectBuilder.add("second", calendar.getFractionalSecond()); } if (calendar.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { objectBuilder.add("timeZone", calendar.getTimezone()); } return objectBuilder.build(); }
Example 10
Source File: SWTClockWidget.java From atdl4j with MIT License | 5 votes |
/** * Used when applying Clock@initValue (xs:time) * @param aValue * @param @InitValueMode */ protected void setAndRenderInitValue( XMLGregorianCalendar aValue, int aInitValueMode ) { if ( aValue != null ) { // -- Note that this will throw IllegalArgumentException if timezone ID // specified cannot be resolved -- DateTimeZone tempLocalMktTz = getLocalMktTz(); logger.debug( "control.getID(): " + control.getID() + " aValue: " + aValue + " getLocalMktTz(): " + tempLocalMktTz ); // -- localMktTz is required when using/interpreting aValue -- if ( tempLocalMktTz == null ) { throw new IllegalArgumentException( "localMktTz is required when aValue (" + aValue + ") is specified. (Control.ID: " + control.getID() + ")" ); } DateTime tempNow = new DateTime( tempLocalMktTz ); DateTime tempInit = new DateTime( ( showMonthYear && aValue.getYear() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getYear() : tempNow.getYear(), ( showMonthYear && aValue.getMonth() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMonth() : tempNow.getMonthOfYear(), ( showMonthYear && aValue.getDay() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getDay() : tempNow.getDayOfMonth(), ( showMonthYear && aValue.getHour() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getHour() : 0, ( showMonthYear && aValue.getMinute() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMinute() : 0, ( showMonthYear && aValue.getSecond() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getSecond(): 0, 0, tempLocalMktTz ); if ( ( aInitValueMode == Atdl4jConstants.CLOCK_INIT_VALUE_MODE_USE_CURRENT_TIME_IF_LATER ) && ( tempNow.isAfter( tempInit ) ) ) { // -- Use current time -- tempInit = tempNow; } // -- Make sure that the value is rendered on the display in local timezone -- setValue( tempInit.withZone( DateTimeZone.getDefault() ) ); } }
Example 11
Source File: SwingJideClockWidget.java From atdl4j with MIT License | 5 votes |
/** * Used when applying Clock@initValue (xs:time) * @param aValue * @param @InitValueMode */ protected void setAndRenderInitValue( XMLGregorianCalendar aValue, int aInitValueMode ) { if ( aValue != null ) { // -- Note that this will throw IllegalArgumentException if timezone ID // specified cannot be resolved -- DateTimeZone tempLocalMktTz = getLocalMktTz(); logger.debug( "control.getID(): " + control.getID() + " aValue: " + aValue + " getLocalMktTz(): " + tempLocalMktTz ); // -- localMktTz is required when using/interpreting aValue -- if ( tempLocalMktTz == null ) { throw new IllegalArgumentException( "localMktTz is required when aValue (" + aValue + ") is specified. (Control.ID: " + control.getID() + ")" ); } DateTime tempNow = new DateTime( tempLocalMktTz ); DateTime tempInit = new DateTime( ( showMonthYear && aValue.getYear() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getYear() : tempNow.getYear(), ( showMonthYear && aValue.getMonth() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMonth() : tempNow.getMonthOfYear(), ( showMonthYear && aValue.getDay() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getDay() : tempNow.getDayOfMonth(), ( showTime && aValue.getHour() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getHour() : 0, ( showTime && aValue.getMinute() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getMinute() : 0, ( showTime && aValue.getSecond() != DatatypeConstants.FIELD_UNDEFINED ) ? aValue.getSecond(): 0, 0, tempLocalMktTz ); if ( ( aInitValueMode == Atdl4jConstants.CLOCK_INIT_VALUE_MODE_USE_CURRENT_TIME_IF_LATER ) && ( tempNow.isAfter( tempInit ) ) ) { // -- Use current time -- tempInit = tempNow; } // -- Make sure that the value is rendered on the display in local timezone -- setValue( tempInit.withZone( DateTimeZone.getDefault() ) ); } }
Example 12
Source File: AbstractTypeTestClient.java From cxf with Apache License 2.0 | 5 votes |
protected boolean equalsDate(XMLGregorianCalendar orig, XMLGregorianCalendar actual) { boolean result = false; if ((orig.getYear() == actual.getYear()) && (orig.getMonth() == actual.getMonth()) && (orig.getDay() == actual.getDay()) && (actual.getHour() == DatatypeConstants.FIELD_UNDEFINED) && (actual.getMinute() == DatatypeConstants.FIELD_UNDEFINED) && (actual.getSecond() == DatatypeConstants.FIELD_UNDEFINED) && (actual.getMillisecond() == DatatypeConstants.FIELD_UNDEFINED)) { result = orig.getTimezone() == actual.getTimezone(); } return result; }
Example 13
Source File: XMLGregorianCalendarTypeInfoCompiler.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 5 votes |
@Override public JSAssignmentExpression createValue(MappingCompiler<T, C> mappingCompiler, String item) { final JSCodeModel codeModel = mappingCompiler.getCodeModel(); final JSObjectLiteral result = codeModel.object(); final XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(item); if (calendar.getYear() != DatatypeConstants.FIELD_UNDEFINED) { result.append("year", codeModel.integer(calendar.getYear())); } if (calendar.getMonth() != DatatypeConstants.FIELD_UNDEFINED) { result.append("month", codeModel.integer(calendar.getMonth())); } if (calendar.getDay() != DatatypeConstants.FIELD_UNDEFINED) { result.append("day", codeModel.integer(calendar.getDay())); } if (calendar.getHour() != DatatypeConstants.FIELD_UNDEFINED) { result.append("hour", codeModel.integer(calendar.getHour())); } if (calendar.getMinute() != DatatypeConstants.FIELD_UNDEFINED) { result.append("minute", codeModel.integer(calendar.getMinute())); } if (calendar.getSecond() != DatatypeConstants.FIELD_UNDEFINED) { result.append("second", codeModel.integer(calendar.getSecond())); } if (calendar.getFractionalSecond() != null) { result.append("second", codeModel.decimal(calendar.getFractionalSecond().toString())); } if (calendar.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { result.append("timeZone", codeModel.integer(calendar.getTimezone())); } return result; }
Example 14
Source File: RuntimeBuiltinLeafInfoImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
private static void checkXmlGregorianCalendarFieldRef(QName type, XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ StringBuilder buf = new StringBuilder(); int bitField = xmlGregorianCalendarFieldRef.get(type); final int l = 0x1; int pos = 0; while (bitField != 0x0){ int bit = bitField & l; bitField >>>= 4; pos++; if (bit == 1) { switch(pos){ case 1: if (cal.getSecond() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_SEC); } break; case 2: if (cal.getMinute() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MIN); } break; case 3: if (cal.getHour() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_HR); } break; case 4: if (cal.getDay() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_DAY); } break; case 5: if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MONTH); } break; case 6: if (cal.getYear() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_YEAR); } break; case 7: // ignore timezone setting break; } } } if (buf.length() > 0){ throw new javax.xml.bind.MarshalException( Messages.XMLGREGORIANCALENDAR_INVALID.format(type.getLocalPart()) + buf.toString()); } }
Example 15
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private static void checkXmlGregorianCalendarFieldRef(QName type, XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ StringBuilder buf = new StringBuilder(); int bitField = xmlGregorianCalendarFieldRef.get(type); final int l = 0x1; int pos = 0; while (bitField != 0x0){ int bit = bitField & l; bitField >>>= 4; pos++; if (bit == 1) { switch(pos){ case 1: if (cal.getSecond() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_SEC); } break; case 2: if (cal.getMinute() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MIN); } break; case 3: if (cal.getHour() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_HR); } break; case 4: if (cal.getDay() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_DAY); } break; case 5: if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MONTH); } break; case 6: if (cal.getYear() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_YEAR); } break; case 7: // ignore timezone setting break; } } } if (buf.length() > 0){ throw new javax.xml.bind.MarshalException( Messages.XMLGREGORIANCALENDAR_INVALID.format(type.getLocalPart()) + buf.toString()); } }
Example 16
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static void checkXmlGregorianCalendarFieldRef(QName type, XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ StringBuilder buf = new StringBuilder(); int bitField = xmlGregorianCalendarFieldRef.get(type); final int l = 0x1; int pos = 0; while (bitField != 0x0){ int bit = bitField & l; bitField >>>= 4; pos++; if (bit == 1) { switch(pos){ case 1: if (cal.getSecond() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_SEC); } break; case 2: if (cal.getMinute() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MIN); } break; case 3: if (cal.getHour() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_HR); } break; case 4: if (cal.getDay() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_DAY); } break; case 5: if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MONTH); } break; case 6: if (cal.getYear() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_YEAR); } break; case 7: // ignore timezone setting break; } } } if (buf.length() > 0){ throw new javax.xml.bind.MarshalException( Messages.XMLGREGORIANCALENDAR_INVALID.format(type.getLocalPart()) + buf.toString()); } }
Example 17
Source File: SignavioBaseDateTimeLib.java From jdmn with Apache License 2.0 | 4 votes |
protected boolean isDateTime(XMLGregorianCalendar dateTime1) { return dateTime1.getYear() >= 0 && dateTime1.getHour() >= 0; }
Example 18
Source File: SignavioBaseDateTimeLib.java From jdmn with Apache License 2.0 | 4 votes |
protected boolean isTime(XMLGregorianCalendar dateTime1) { return dateTime1.getYear() < 0 && dateTime1.getHour() >= 0; }
Example 19
Source File: SignavioBaseDateTimeLib.java From jdmn with Apache License 2.0 | 4 votes |
protected boolean isDate(XMLGregorianCalendar dateTime) { return dateTime.getYear() >= 0 && dateTime.getHour() < 0; }
Example 20
Source File: RuntimeBuiltinLeafInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static void checkXmlGregorianCalendarFieldRef(QName type, XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ StringBuilder buf = new StringBuilder(); int bitField = xmlGregorianCalendarFieldRef.get(type); final int l = 0x1; int pos = 0; while (bitField != 0x0){ int bit = bitField & l; bitField >>>= 4; pos++; if (bit == 1) { switch(pos){ case 1: if (cal.getSecond() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_SEC); } break; case 2: if (cal.getMinute() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MIN); } break; case 3: if (cal.getHour() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_HR); } break; case 4: if (cal.getDay() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_DAY); } break; case 5: if (cal.getMonth() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_MONTH); } break; case 6: if (cal.getYear() == DatatypeConstants.FIELD_UNDEFINED){ buf.append(" ").append(Messages.XMLGREGORIANCALENDAR_YEAR); } break; case 7: // ignore timezone setting break; } } } if (buf.length() > 0){ throw new javax.xml.bind.MarshalException( Messages.XMLGREGORIANCALENDAR_INVALID.format(type.getLocalPart()) + buf.toString()); } }