Domanda

My android application had worked fine since a few months ago.

I used a parsing in this way:

String xmlString = Utilities.Unmarshall(appFramework.ordine);

where ordine is an instance of the class Servizi:

@Root(name = "Ordine")
public class Servizi {

@Element(name = "data_richiesta")
    public Calendar DataRichiesta;

//other elements

public Servizi() {
        DataDesideratoDa = Calendar.getInstance();
    }
}

I used the library org.simpleframework.xml.core.Persister;

Some months ago this produced something like this:

<data_richiesta class="java.util.GregorianCalendar">2012-11-16 17:55:10.216 GMT+01:00</data_richiesta>

while today it produces:

<data_richiesta class="java.util.GregorianCalendar">2013-06-26 16:26:02.0 CEST</data_richiesta>

I have not changed anything in my application, but now I always obtain the CEST format, while some months ago I obtained GMT format.

È stato utile?

Soluzione

Calendar.getInstance()

http://docs.oracle.com/javase/6/docs/api/java/util/Calendar.html#getInstance()

Gets a calendar using the default time zone and locale. The Calendar returned is based on the current time in the default time zone with the default locale.

What's happened is we are now in summer, so your device's time zone has changed. Every year, twice a year in many countries the time zone actually changes: https://en.wikipedia.org/wiki/Daylight_saving_time

You should probably specify a timezone in your code, and probably use UTC, which doesn't change:

Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top