Java Code Examples for javax.xml.datatype.XMLGregorianCalendar#clone()
The following examples show how to use
javax.xml.datatype.XMLGregorianCalendar#clone() .
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: DefaultDateTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateTimeAddDuration(XMLGregorianCalendar xmlGregorianCalendar, Duration duration) { if (xmlGregorianCalendar == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) xmlGregorianCalendar.clone(); clone.add(duration); return clone; } catch (Exception e) { String message = String.format("dateTimeSubtract(%s, %s)", xmlGregorianCalendar, duration); logError(message, e); return null; } }
Example 2
Source File: XMLTimeUtil.java From keycloak with Apache License 2.0 | 6 votes |
/** * Add additional time in miliseconds * * @param value calendar whose value needs to be updated * @param millis * * @return calendar value with the addition */ public static XMLGregorianCalendar add(XMLGregorianCalendar value, long millis) { if (value == null) { return null; } XMLGregorianCalendar newVal = (XMLGregorianCalendar) value.clone(); if (millis == 0) { return newVal; } Duration duration; duration = DATATYPE_FACTORY.get().newDuration(millis); newVal.add(duration); return newVal; }
Example 3
Source File: DefaultSignavioDateType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateSubtractDuration(XMLGregorianCalendar date, Duration duration) { if (date == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) date.clone(); clone.add(duration.negate()); return clone; } catch (Exception e) { String message = String.format("dateSubtract(%s, %s)", date, duration); logError(message, e); return null; } }
Example 4
Source File: DefaultSignavioDateType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateAddDuration(XMLGregorianCalendar date, Duration duration) { if (date == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) date.clone(); clone.add(duration); return clone; } catch (Exception e) { String message = String.format("dateAdd(%s, %s)", date, duration); logError(message, e); return null; } }
Example 5
Source File: DefaultSignavioDateTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateTimeSubtractDuration(XMLGregorianCalendar xmlGregorianCalendar, Duration duration) { if (xmlGregorianCalendar == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) xmlGregorianCalendar.clone(); clone.add(duration.negate()); return clone; } catch (Exception e) { String message = String.format("dateTimeSubtract(%s, %s)", xmlGregorianCalendar, duration); logError(message, e); return null; } }
Example 6
Source File: DefaultSignavioDateTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateTimeAddDuration(XMLGregorianCalendar xmlGregorianCalendar, Duration duration) { if (xmlGregorianCalendar == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) xmlGregorianCalendar.clone(); clone.add(duration); return clone; } catch (Exception e) { String message = String.format("dateTimeSubtract(%s, %s)", xmlGregorianCalendar, duration); logError(message, e); return null; } }
Example 7
Source File: DefaultSignavioTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar timeSubtractDuration(XMLGregorianCalendar time, Duration duration) { if (time == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) time.clone(); clone.add(duration.negate()); return clone; } catch (Exception e) { String message = String.format("timeSubtract(%s, %s)", time, duration); logError(message, e); return null; } }
Example 8
Source File: DefaultSignavioTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar timeAddDuration(XMLGregorianCalendar time, Duration duration) { if (time == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) time.clone(); clone.add(duration); return clone; } catch (Exception e) { String message = String.format("timeAdd(%s, %s)", time, duration); logError(message, e); return null; } }
Example 9
Source File: DefaultDateType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateSubtractDuration(XMLGregorianCalendar date, Duration duration) { if (date == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) date.clone(); clone.add(duration.negate()); return clone; } catch (Exception e) { String message = String.format("dateSubtract(%s, %s)", date, duration); logError(message, e); return null; } }
Example 10
Source File: DefaultDateType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateAddDuration(XMLGregorianCalendar date, Duration duration) { if (date == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) date.clone(); clone.add(duration); return clone; } catch (Exception e) { String message = String.format("dateAdd(%s, %s)", date, duration); logError(message, e); return null; } }
Example 11
Source File: DefaultTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar timeSubtractDuration(XMLGregorianCalendar time, Duration duration) { if (time == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) time.clone(); clone.add(duration.negate()); return clone; } catch (Exception e) { String message = String.format("timeSubtract(%s, %s)", time, duration); logError(message, e); return null; } }
Example 12
Source File: DefaultTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar timeAddDuration(XMLGregorianCalendar time, Duration duration) { if (time == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) time.clone(); clone.add(duration); return clone; } catch (Exception e) { String message = String.format("timeAdd(%s, %s)", time, duration); logError(message, e); return null; } }
Example 13
Source File: DefaultTimeLib.java From jdmn with Apache License 2.0 | 6 votes |
public XMLGregorianCalendar time(XMLGregorianCalendar from) { if (from == null) { return null; } FEELXMLGregorianCalendar calendar = (FEELXMLGregorianCalendar) from.clone(); if (from.getXMLSchemaType() == DatatypeConstants.DATE) { calendar.setYear(DatatypeConstants.FIELD_UNDEFINED); calendar.setMonth(DatatypeConstants.FIELD_UNDEFINED); calendar.setDay(DatatypeConstants.FIELD_UNDEFINED); calendar.setHour(0); calendar.setMinute(0); calendar.setSecond(0); calendar.setZoneID("Z"); } else if (from.getXMLSchemaType() == DatatypeConstants.DATETIME) { calendar.setYear(DatatypeConstants.FIELD_UNDEFINED); calendar.setMonth(DatatypeConstants.FIELD_UNDEFINED); calendar.setDay(DatatypeConstants.FIELD_UNDEFINED); } return this.isValidTime(calendar) ? calendar : null; }
Example 14
Source File: DefaultDateTimeType.java From jdmn with Apache License 2.0 | 6 votes |
@Override public XMLGregorianCalendar dateTimeSubtractDuration(XMLGregorianCalendar xmlGregorianCalendar, Duration duration) { if (xmlGregorianCalendar == null || duration == null) { return null; } try { XMLGregorianCalendar clone = (XMLGregorianCalendar) xmlGregorianCalendar.clone(); clone.add(duration.negate()); return clone; } catch (Exception e) { String message = String.format("dateTimeSubtract(%s, %s)", xmlGregorianCalendar, duration); logError(message, e); return null; } }
Example 15
Source File: DefaultSignavioDateLib.java From jdmn with Apache License 2.0 | 5 votes |
public XMLGregorianCalendar yearAdd(XMLGregorianCalendar dateTime, BigDecimal yearsToAdd) { XMLGregorianCalendar result = (XMLGregorianCalendar) dateTime.clone(); int months = yearsToAdd.intValue(); boolean isPositive = months > 0; Duration duration; duration = DATA_TYPE_FACTORY.newDurationYearMonth( isPositive, yearsToAdd.abs().intValue(), 0); result.add(duration); return result; }
Example 16
Source File: DefaultSignavioDateLib.java From jdmn with Apache License 2.0 | 5 votes |
public XMLGregorianCalendar monthAdd(XMLGregorianCalendar dateTime, BigDecimal monthsToAdd) { XMLGregorianCalendar result = (XMLGregorianCalendar) dateTime.clone(); int months = monthsToAdd.intValue(); boolean isPositive = months > 0; Duration duration; duration = DATA_TYPE_FACTORY.newDurationYearMonth( isPositive, 0, monthsToAdd.abs().intValue()); result.add(duration); return result; }
Example 17
Source File: DefaultSignavioDateLib.java From jdmn with Apache License 2.0 | 5 votes |
public XMLGregorianCalendar dayAdd(XMLGregorianCalendar dateTime, BigDecimal daysToAdd) { XMLGregorianCalendar result = (XMLGregorianCalendar) dateTime.clone(); int days = daysToAdd.intValue(); boolean isPositive = days > 0; Duration duration; duration = DATA_TYPE_FACTORY.newDurationDayTime( isPositive, daysToAdd.abs().intValue(), 0, 0, 0); result.add(duration); return result; }
Example 18
Source File: DefaultDateLib.java From jdmn with Apache License 2.0 | 5 votes |
public XMLGregorianCalendar date(XMLGregorianCalendar from) { if (from == null) { return null; } FEELXMLGregorianCalendar calendar = (FEELXMLGregorianCalendar) from.clone(); calendar.setTime(DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED); calendar.setZoneID(null); return this.isValidDate(calendar) ? calendar : null; }
Example 19
Source File: XMLGregorianCalendarTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "data-for-add") public void checkAddDays(String cal1, String cal2, String dur) { XMLGregorianCalendar calendar1 = datatypeFactory.newXMLGregorianCalendar(cal1); XMLGregorianCalendar calendar2 = datatypeFactory.newXMLGregorianCalendar(cal2); Duration duration = datatypeFactory.newDuration(dur); XMLGregorianCalendar calendar1Clone = (XMLGregorianCalendar)calendar1.clone(); calendar1Clone.add(duration); assertEquals(calendar1Clone, calendar2); calendar2.add(duration.negate()); assertEquals(calendar2, calendar1); }