Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

xjc mark-generated sometimes produces a wrong date value #1105

Open
glassfishrobot opened this issue Sep 15, 2016 · 5 comments
Open

xjc mark-generated sometimes produces a wrong date value #1105

glassfishrobot opened this issue Sep 15, 2016 · 5 comments

Comments

@glassfishrobot
Copy link
Contributor

When using the parameter "-mark-generated" to generate the @generated annotation, the content of the date attribute may be wrong.

In fact, the PM dates are wrong as they stay at the AM format.

It's because the date pattern used for generating the ISO-8601 string is wrong.
It's "yyyy-MM-dd'T'hh:mm:ssZ" but it should be "yyyy-MM-dd'T'HH:mm:ssZ"

The code to fix is in com.sun.tools.xjc.addon.at_generated.PluginImpl

private String getISO8601Date() {
        if(date==null) {
            StringBuffer tstamp = new StringBuffer();
            tstamp.append((new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ")).format(new Date()));
            // hack to get ISO 8601 style timezone - is there a better way that doesn't require
            // a bunch of timezone offset calculations?
            tstamp.insert(tstamp.length()-2, ':');
            date = tstamp.toString();
        }
        return date;
    }

Maven artifact : com.sun.xml.bind:jaxb-xjc:2.2.11

Thanks.

Environment

JDK 8, JDK 7

Affected Versions

[2.2.11]

@glassfishrobot
Copy link
Contributor Author

Reported by ghusta

@glassfishrobot
Copy link
Contributor Author

Was assigned to yaroska

@glassfishrobot
Copy link
Contributor Author

michael-o said:
There is also another issue here: If the timezone is UTC, there must be a Z and not +00:00, so there are two bugs here.

@glassfishrobot
Copy link
Contributor Author

michael-o said:
The value has actually to be yyyy-MM-dd'T'HH:mm:ssXXX.

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA JAXB-1105

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant