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

  • Home
  • SEARCH
  • 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 8587559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:35:53+00:00 2026-06-11T22:35:53+00:00

I receive an XML response with an attribute which contains following value: Wed Sep

  • 0

I receive an XML response with an attribute which contains following value:

Wed Sep 05 10:56:13 CEST 2012

I have defined in my model class a field with annotation:

@Attribute(name = "regDate")
private Date registerDate;

However it throws an exception:

java.text.ParseException: Unparseable date: "Wed Sep 05 10:56:13 CEST 2012" (at offset 0)

Is it possible to define date format in SimpleFramework‘s annotations ?

What format should cover this date string ?

  • 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-11T22:35:54+00:00Added an answer on June 11, 2026 at 10:35 pm

    SimpleXML only supports some DateFormat‘s:

    • yyyy-MM-dd HH:mm:ss.S z
    • yyyy-MM-dd HH:mm:ss z
    • yyyy-MM-dd z
    • yyyy-MM-dd

    (For the meaning of each character see SimpleDateFormat API Doc (Java SE 7))

    However it’s possible to write a custom Transform who deals with other formats:

    Transform

    public class DateFormatTransformer implements Transform<Date>
    {
        private DateFormat dateFormat;
    
    
        public DateFormatTransformer(DateFormat dateFormat)
        {
            this.dateFormat = dateFormat;
        }
    
    
    
        @Override
        public Date read(String value) throws Exception
        {
            return dateFormat.parse(value);
        }
    
    
        @Override
        public String write(Date value) throws Exception
        {
            return dateFormat.format(value);
        }
    
    }
    

    Corresponding Annotation

    @Attribute(name="regDate", required=true) /* 1 */
    private Date registerDate;
    

    Note 1: required=true is optional

    How to use it

    // Maybe you have to correct this or use another / no Locale
    DateFormat format = new SimpleDateFormat("EE MMM dd HH:mm:ss z YYYY", Locale.US);
    
    
    RegistryMatcher m = new RegistryMatcher();
    m.bind(Date.class, new DateFormatTransformer(format));
    
    
    Serializer ser = new Persister(m);
    Example e = ser.read(Example.class, xml);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using AJAX to receive an XML response, which I then need to manipulate.
I want to receive my response XML in following format... <PersonDetails> <Name>Ajay</Name> <Age>29</Age> <ContactDetails>
I receive a daily XML file that contains thousands of records, each being a
I have an XML reader but I receive an error when I'm trying to
I have a test script to receive an xml file via http post and
I have a sample htm file with following structure and it POSTs the xml
Background I have written a test suite in mstest which has a template XML.
I have the following Soap Request I receive from the client, where basically I
I am working on a project that will receive HTTP POSTs which contain XML
I am using Chrome 10 to receive a web service response in XML. 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.