/** * <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); }
ErrorUtils.RuntimeErrors.ILLEGAL_STATE.throwRuntime("Unable to set the begin time due to", e); gTime.setFractionalSecond(null); LOG.info("Begin Time: {}", gTime); request.setExclusiveBeginTimestamp(gTime);
@Override public void setFractionalSecond(BigDecimal fractionalSecond) { xmlGregorianCalendar.setFractionalSecond(fractionalSecond); }
@Override public void setFractionalSecond(BigDecimal fractionalSecond) { xmlGregorianCalendar.setFractionalSecond(fractionalSecond); }
public void setFractionalSecond( BigDecimal fractional ) { calendar.setFractionalSecond( fractional ); }
public void setFractionalSecond( BigDecimal fractional ) { calendar.setFractionalSecond( fractional ); }
public Literal serialize(Timestamp object) { GregorianCalendar gc = new GregorianCalendar(0, 0, 0); gc.setTime(object); XMLGregorianCalendar xgc = factory.newXMLGregorianCalendar(gc); BigDecimal fraction = BigDecimal.valueOf(object.getNanos(), 9); xgc.setFractionalSecond(fraction); String label = xgc.toXMLFormat(); return vf.createLiteral(label, datatype); }
public Literal serialize(Timestamp object) { GregorianCalendar gc = new GregorianCalendar(0, 0, 0); gc.setTime(object); XMLGregorianCalendar xgc = factory.newXMLGregorianCalendar(gc); BigDecimal fraction = BigDecimal.valueOf(object.getNanos(), 9); xgc.setFractionalSecond(fraction); String label = xgc.toXMLFormat(); return vf.createLiteral(label, datatype); }
public Literal serialize(Timestamp object) { GregorianCalendar gc = new GregorianCalendar(0, 0, 0); gc.setTime(object); XMLGregorianCalendar xgc = factory.newXMLGregorianCalendar(gc); BigDecimal fraction = BigDecimal.valueOf(object.getNanos(), 9); xgc.setFractionalSecond(fraction); String label = xgc.toXMLFormat(); return vf.createLiteral(label, datatype); }
@Override public XMLGregorianCalendar deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { try { JsonObject obj = jsonElement.getAsJsonObject(); XMLGregorianCalendar xmlGregCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar( obj.get(YEAR).getAsInt(), obj.get(MONTH).getAsInt(), obj.get(DAY).getAsInt(), obj.get(HOUR).getAsInt(), obj.get(MINUTE).getAsInt(), obj.get(SECOND).getAsInt(), 0, obj.get(TIMEZONE).getAsInt()); xmlGregCalendar.setFractionalSecond(obj.get(FRACTIONAL).getAsBigDecimal()); return xmlGregCalendar; // use the line below as implementation in Java 8 //return DatatypeFactory.newInstance().newXMLGregorianCalendar(jsonElement.getAsString()); } catch (Exception e) { e.printStackTrace(); return null; } }
/** * Converts a given {@code Date} to a new {@code XMLGregorianCalendar}. * * @param date the date to be converted * @return the new {@code XMLGregorianCalendar} or null */ public static XMLGregorianCalendar createXMLGregorianCalendar(final Date date) { if (date == null) { return null; } final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); try { XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); xmlGregorianCalendar.setFractionalSecond(null); xmlGregorianCalendar = xmlGregorianCalendar.normalize(); // to UTC = Zulu return xmlGregorianCalendar; } catch (DatatypeConfigurationException e) { // LOG.warn("Unable to properly convert a Date to an XMLGregorianCalendar",e); } return null; }
/** * Converts a given {@code Date} to a new {@code XMLGregorianCalendar}. * * @param date * the date to be converted * @return the new {@code XMLGregorianCalendar} or null */ public static XMLGregorianCalendar createXMLGregorianCalendar(final Date date) { if (date == null) { return null; } final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); try { XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); xmlGregorianCalendar.setFractionalSecond(null); return xmlGregorianCalendar.normalize(); // to UTC = Zulu } catch (DatatypeConfigurationException e) { LOG.warn("Unable to properly convert a Date to an XMLGregorianCalendar " + e.getMessage(), e); } return null; }
public static XMLGregorianCalendar formatXMLTime(CompactCalendar time, boolean reduceTimeToSecondPrecision) { if (time == null) return null; try { GregorianCalendar gregorianCalendar = toUTC(time.getCalendar()); XMLGregorianCalendar result = getDataTypeFactory().newXMLGregorianCalendar(gregorianCalendar); if (reduceTimeToSecondPrecision) result.setFractionalSecond(null); return result; } catch (DatatypeConfigurationException e) { return null; } }
/** * <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); }
/** * <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); }
/** * <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); }
/** * <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); }
/** * <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); }
/** * <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); }
cal.setMinute(ldt.getMinute()); cal.setSecond(ldt.getSecond()); cal.setFractionalSecond(new BigDecimal("0." + ldt.getNano()));