Java Code Examples for javax.xml.datatype.XMLGregorianCalendar#getFractionalSecond()
The following examples show how to use
javax.xml.datatype.XMLGregorianCalendar#getFractionalSecond() .
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: 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 2
Source File: Seconds.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("SECONDS 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 seconds = calValue.getSecond(); if (DatatypeConstants.FIELD_UNDEFINED != seconds) { BigDecimal fraction = calValue.getFractionalSecond(); String str = (fraction == null) ? String.valueOf(seconds) : String.valueOf(fraction.doubleValue() + seconds); return valueFactory.createLiteral(str, XMLSchema.DECIMAL); } else { throw new ValueExprEvaluationException("can not determine minutes 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 3
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 4
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(); }