mercredi 24 juillet 2019

Parse exception in test environment, while in Android environment works fine

I have a very simple instruction in Android:

new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ").parse("2019-07-24T21:27:09+02:00")

The same instruction, when runs on a real device, generates the right output: a Date object that can be represented by Wed Jul 24 21:27:09 GMT+02:00 2019

However when I use the exact same instruction in a unit test (with junit), it gives me java.text.ParseException.

I can make it work removing the last : (like this, "2019-07-24T21:27:09+0200"), but I am wondering why. I understand they use different JVM, but the Android APIs used should be the same.

Aucun commentaire:

Enregistrer un commentaire