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 7758019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:14:53+00:00 2026-06-01T13:14:53+00:00

I have a relatively simple class. I serialize it using JDK 1.7 on my

  • 0

I have a relatively simple class. I serialize it using JDK 1.7 on my server, and deserialize it using Android 2.2 on my client, both of which are using simple xml 2.6.2. The class contains a Date field which I annotate with @Attribute. Resulting XML looks something like this:

<daySchedule id="e086b34c-2836-4ecb-af36-5764e3f44b21" date="2012-03-29 00:00:00.0 BST">
      <driver id="022cbb89-1226-4d85-ac28-b4848f3bc4ae" name="Julian"/>
      <job id="1e444bf0-59ec-44f6-8f94-01e8606caa27" scheduledStartTime="2012-03-27 23:05:00.0 BST">
         <location id="8c00f18a-fc97-4f2c-a369-ec4efe62f4bb" clientId="92797509-600c-47b4-989d-150c7e695e95" name="The Phantom Coach">
             <gpsPoint latitude="52.390499114990234" longitude="-1.5485700368881226"/>
         </location>
         <task id="c6adff66-b342-4d24-874a-e676ce720af8" locationId="8c00f18a-fc97-4f2c-a369-ec4efe62f4bb" name="Have a drink" description="Something non-alcoholic, probably Diet Pepsi."/>
       </job>
    </daySchedule>

When I try to deserialize it, the exception I get is:

03-29 14:06:58.975: W/System.err(1583): java.text.ParseException: Unparseable date: 2012-03-29 00:00:00.0 BST
03-29 14:06:58.975: W/System.err(1583):     at java.text.DateFormat.parse(DateFormat.java:645)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.transform.DateType$DateFormat.getDate(DateType.java:189)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.transform.DateType.getDate(DateType.java:112)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.transform.DateTransform.read(DateTransform.java:75)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.transform.DateTransform.read(DateTransform.java:44)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.transform.Transformer.read(Transformer.java:104)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Support.read(Support.java:185)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:105)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Primitive.readTemplate(Primitive.java:231)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Primitive.read(Primitive.java:171)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Primitive.read(Primitive.java:126)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.readVariable(Composite.java:687)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.readInstance(Composite.java:635)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.readAttribute(Composite.java:558)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.readAttributes(Composite.java:474)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.readSection(Composite.java:387)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.read(Composite.java:367)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.readDefault(Composite.java:262)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.read(Composite.java:232)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.read(Composite.java:202)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Composite.read(Composite.java:150)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Persister.read(Persister.java:632)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Persister.read(Persister.java:613)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Persister.read(Persister.java:591)
03-29 14:06:58.985: W/System.err(1583):     at org.simpleframework.xml.core.Persister.read(Persister.java:550)
03-29 14:06:58.995: W/System.err(1583):     at org.simpleframework.xml.core.Persister.read(Persister.java:451)
03-29 14:06:58.995: W/System.err(1583):     at net.meridiandigital.binco.demo.LocationList$2.doInBackground(LocationList.java:78)
03-29 14:06:58.995: W/System.err(1583):     at net.meridiandigital.binco.demo.LocationList$2.doInBackground(LocationList.java:1)
03-29 14:06:58.995: W/System.err(1583):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
03-29 14:06:58.995: W/System.err(1583):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-29 14:06:58.995: W/System.err(1583):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-29 14:06:58.995: W/System.err(1583):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-29 14:06:58.995: W/System.err(1583):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-29 14:06:58.995: W/System.err(1583):     at java.lang.Thread.run(Thread.java:1096)

There’s a possibility that this is related to the problem discussed at Java: unparseable date exception but my question is how do I work around this issue? Is there a way I can fix the date processing in simple xml so that it avoids using the buggy code in Android?

Update 1:

Interesting data point, here is a date from a document generated on the Android device:

2012-03-30 07:00:38.552 GMT+01:00

This, it seems, works fine. So, perhaps there’s a way to persuade Java on the server to produce dates in this format, rather than using ‘BST’ (or presumably other similar timezone names)?

  • 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-01T13:14:54+00:00Added an answer on June 1, 2026 at 1:14 pm

    I never did find a way to tell the system to not use symbolic timezone names. I could almost get the right date format by using the RFC822-compatible timezone support in SimpleDateFormat, but it wasn’t quite right. In the end, I simply decided to force the system to use times in GMT:

    private static final class GMTDateTransform implements Transform<Date>
    {
        ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat> () {
            protected SimpleDateFormat initialValue ()
            {
                SimpleDateFormat r = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS zzz");
                r.setTimeZone (TimeZone.getTimeZone ("GMT"));
                return r;
            }
        };
    
        public Date read (String source) throws Exception 
        {
            return sdf.get ().parse (source);
        }
        public String write (Date source) throws Exception
        {
            return sdf.get ().format (source);
        }
    }
    

    I then used a Matcher that returned a static instance of GMTDateTransform when asked to match the Date class, and passed that to Persister when I created it:

        final GMTDateTransform transform = new GMTDateTransform();
        return new Persister(new Matcher() {
            @Override
            public Transform match(Class cls) throws Exception {
                if (cls == Date.class) return transform;
                return null;
            }
        });
    

    (the above code is a simplification of what my actual code does, because I have other classes with custom transforms, and use a hashmap of class to transform mappings to find the correct one)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a (relatively) simple tcp client/server chat program for my
I have a relatively simple application which I need to make native Mac OSX
I'm using WPF with .NET 3.0. I have a relatively simple DataTemplate defined as
I have a relatively simple package of 8 Java classes generated from an XML
Right now I have a relatively simple class setup: class A{ //stuff } class
I have a relatively simple abstract class. I've simplified it further for this question.
I am using Spring 3.0.2. I have two relatively simple bean definitions. One has
A relatively simple question. I have a datagridview, which all it does is displays
I have a set of classes and interfaces which have a relatively simple hierarchy,
I have a relatively simple query joining two tables. The Where criteria can be

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.