Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:09:35+00:00 2026-06-06T15:09:35+00:00

I have xsd schema file which I can’t change. Here is an excerpt that

  • 0

I have xsd schema file which I can’t change.
Here is an excerpt that makes my problem:

<xs:element name="Event" maxOccurs="unbounded">
    <xs:complexType>
        <xs:all>
            <xs:element name="EventDate" type="xs:string" minOccurs="0">
...

Here is an example of string data I get for EventDate:

2012-05-30T12:30:00 CEST

I’m compiling with xjc and I get Event class with String field.
Is there a way to get Event class with some kind of Date field?
I guess I should write some kind of adapter and that’s ok but I don’t know how to tell xjc to use it only on EventDate element.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:09:38+00:00Added an answer on June 6, 2026 at 3:09 pm

    I’m compiling with:

    xjc -b temp.xml schema.xsd
    

    This is part of temp.xml:

        <jaxb:bindings node="//xs:element[@name='EventDate']">
            <jaxb:property>
                <jaxb:baseType>
                    <javaType name="java.util.Date"
                        parseMethod="com.mydomain.adapters.DateAdapter.parseDate"
                        printMethod="com.mydomain.adapters.DateAdapter.printDate"
                    />
                </jaxb:baseType>
            </jaxb:property>
        </jaxb:bindings>
    

    And here is part of com.mydomain.adapters.DateAdapter class:

    private static final DateFormatter df = new DateFormatter("yyyy-MM-dd'T'HH:mm:ss z");
    public static Date parseDate(String v) {
        Date date = null;
        try {
            date = df.parse(v, Locale.getDefault());
        } catch (ParseException e) {
            throw new MyException("Could not parse date:" + v);
        }
        return date;
    }
    
    public static String printDate(Date v) {
        return df.print(v, Locale.getDefault());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gigantic QuickBooks SDK .XSD schema file which defines XML requests/responses that
I have an XSD file which contains the schema for my XML. The XSD
I have an XML Schema Definition file .XSD who's elements are in Spanish. I
I have one xsd file I'd rather not modify (Exceptions.xsd): <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns=http://me.com/Exceptions.xsd targetNamespace=http://me.com/Exceptions.xsd
I have an XSD which was transformed from a RELAX NG schema with a
I have an xml message that is in the older schema (xsd) format. My
I have a schema (xsd), and I want to create xml files that conform
I have generated a LinqtoSQL mapping xml file, which I have a valid XSD
I have a simple doc.xml file which contains a single root element with a
I have some XML and an XML Schema in a local xsd file. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.