mercredi 8 février 2017

Behaviour of GregorianCalendar in different Android API's

Vote count: 0

My problem is, that the GregorianCalendar behaves different, depending on the API I use. And I don't know how to handle without having a big hack in my code.

To illustrate:

My Code:
        GregorianCalendar greg = new GregorianCalendar();
        greg.set(-3000,10,10);
        Log.v("GREGTEST","greg : " + greg.get(Calendar.YEAR) + " " + greg.get(Calendar.ERA));
//      System.out.println("greg : " + greg.get(Calendar.YEAR) + " " + greg.get(Calendar.ERA));
        greg.add(Calendar.YEAR, -1000);
        Log.v("GREGTEST","greg : " + greg.get(Calendar.YEAR) + " " + greg.get(Calendar.ERA));

in API 23 I get the results:

GREGTEST: greg : 3001 0
GREGTEST: greg : 2001 0

in API 25 I get the results:

GREGTEST: greg : 3001 0
GREGTEST: greg : 4001 0

It seems to be a Bug.

How yould you handle this situation without checking every API ?

asked 28 secs ago

Let's block ads! (Why?)



Behaviour of GregorianCalendar in different Android API's

Aucun commentaire:

Enregistrer un commentaire