I'm using SimpleDateFormat
with format yyyy-MM-dd'T'HH:mm:ssZZZZZ
. The expected output is "2014-08-26T13:00:14+03:00". However, "ZZZZZ" is only supported since Android 4.3.
Here is the result:
Note that the timezone section is different (03:00 vs 0300)
I have looked at this bug report: http://code.google.com/p/android/issues/detail?id=73209.
Is it possible to get same timezone format in all version like above 4.3? Any suggestions?
This is what I use, no version check:
String result = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZZZZZ").format(calendar.getTime());
//fix up for older Android where ZZZZZ does not include colon
if (!result.substring(result.length() - 3).startsWith(":")) {
result = result.substring(0, result.length() - 2) + ":" + result.substring(result.length() - 2);
}
return result;
you can try this format: ("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With