You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AbstractXMLGregorianCalendarAdapter delegates to concrete implementations for setting varying combinations of fields of Date on an XMLGregorianCalendar.
Two implementations, namely
XMLGregorianCalendarAsTime and
XMLGregorianCalendarAsDateTime
also set milliseconds on the target calendar.
This is done with this line of code: calendar.setMillisecond((int) (date.getTime() % 1000));
The problem here is, that the value resulting from calling date.getTime() may be negative in cases where date is before the beginning of 1970-01-01 (possibly OS dependent).
This will leave the modulo of the negative value also negative and cause an IllegalArgumentException as setMillisecond is called with that value.
AbstractXMLGregorianCalendarAdapter delegates to concrete implementations for setting varying combinations of fields of Date on an XMLGregorianCalendar.
Two implementations, namely
also set milliseconds on the target calendar.
This is done with this line of code:
calendar.setMillisecond((int) (date.getTime() % 1000));
The problem here is, that the value resulting from calling date.getTime() may be negative in cases where date is before the beginning of 1970-01-01 (possibly OS dependent).
This will leave the modulo of the negative value also negative and cause an IllegalArgumentException as setMillisecond is called with that value.
A possible fix might look as follows:
The text was updated successfully, but these errors were encountered: