Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Fix/new feature for Bug 404069 - MOXy should not append .0 to time info for dateTime and time formats + unit test #1403

Conversation

rfelcman
Copy link
Contributor

@rfelcman rfelcman commented Jan 20, 2022

This new feature optionally add suffix/decimal part to time part/seconds in case of conversion from supported date/time formats into String. This suffix is controlled by new org.eclipse.persistence.xml.time.suffix system property.
It happens only if source time doesn't contain fraction of seconds and for XML, JSON conversion. E.g.:
For -Dorg.eclipse.persistence.xml.time.suffix=.0
Source value: 2003-08-29T03:00:00-04:00 -> Output string: 2003-08-29T03:00:00.0-04:00
Source value: 1975-02-21T07:47:15 -> Output string: 1975-02-21T07:47:15.0

It simplifies migration from WebLogic Server 11g to 12c.

Origin bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404069

Signed-off-by: Radek Felcman [email protected]

…dateTime and time formats + unit test

Signed-off-by: Radek Felcman <[email protected]>
@rfelcman rfelcman changed the title Fix/new feature for Bug 404069 - MOXy should not append .0 to time info for dateTime and time formats + unit test [master] Fix/new feature for Bug 404069 - MOXy should not append .0 to time info for dateTime and time formats + unit test Jan 20, 2022
Copy link
Member

@lukasj lukasj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Would it make sense to have different default in master and in older releases?

@rfelcman
Copy link
Contributor Author

This PR doesn't change default/current behavior. It works according:

DatatypeFactory df = DatatypeFactory.newInstance();
XMLGregorianCalendar xmlGregorianCalendar1 = df.newXMLGregorianCalendarTime(14, 12, 23, 20, 0);
assertEquals("14:12:23.020Z", xmlGregorianCalendar1.toXMLFormat());
XMLGregorianCalendar xmlGregorianCalendar2 = df.newXMLGregorianCalendarTime(14, 12, 23, 0);
assertEquals("14:12:23Z", xmlGregorianCalendar2.toXMLFormat());

BigDecimal number15 = new BigDecimal(1.5);
assertEquals("1.5", number15.toString());
BigDecimal number1 = new BigDecimal(1);
assertEquals("1", number1.toString());
BigDecimal number10 = new BigDecimal(1.0);
assertEquals("1", number1.toString());

@rfelcman rfelcman merged commit 1bef069 into eclipse-ee4j:master Jan 24, 2022
@rfelcman rfelcman deleted the bug_moxy_404069_MOXyShouldNotAppend.0ToTime branch January 26, 2022 08:38
dazey3 pushed a commit to dazey3/eclipselink that referenced this pull request Jan 26, 2022
…dateTime and time formats + unit test (eclipse-ee4j#1403)

This new feature optionally add suffix/decimal part to time part/seconds in case of conversion from supported date/time formats into String. This suffix is controlled by new "org.eclipse.persistence.xml.time.suffix" system property.
It happens only if source time doesn't contain fraction of seconds and for XML, JSON conversion. E.g.:
For -Dorg.eclipse.persistence.xml.time.suffix=.0
Source value: 2003-08-29T03:00:00-04:00 -> Output string: 2003-08-29T03:00:00.0-04:00
Source value: 1975-02-21T07:47:15 -> Output string: 1975-02-21T07:47:15.0

In case of fraction of seconds in the input behavior is still same e.g.:
Source value: 1975-02-21T07:47:15.123 -> Output string: 1975-02-21T07:47:15.123

It simplifies migration from WebLogic Server 11g to 12c.
Signed-off-by: Radek Felcman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants