question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

xjc mark-generated sometimes produces a wrong date value

See original GitHub issue

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]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lukasjcommented, Jun 3, 2021

2.3.4/3.0.1 having the fix are out already

0reactions
volkert-fastnedcommented, Mar 26, 2021

Any news on this? I just encountered this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2. XJC Ant Task - Java EE
A change in a schema or an external binding file often results in a Java file that stops being generated. To avoid such...
Read more >
Getting Wrong Date Using XMLGregorianCalender
Calendar.YEAR is a contanst that represents the year field, not the year value (and its value is 1, that's why you're getting year...
Read more >
Apache CXF Development Guide Red Hat Fuse 7.3
This element is where specifics such as parameter order and return values are ... However, the message in Example 10.2, “Invalid XML Binding...
Read more >
Part III Web Services (The Java EE 5 Tutorial)
A client creates a proxy (a local object representing the service) and then simply invokes ... @XmlAnyElement ( lax = false, value =...
Read more >
JAXB Release Documentation | Manualzz
JAXB-598 [https://github.com/javaee/jaxb-v2/issues/598]: XJC generates ordered ... wrong default value for "target" parameter for xjc ant task.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found