From f247c76020e936e2016a85293e19b4f553440030 Mon Sep 17 00:00:00 2001 From: Jin Seok Park Date: Thu, 23 Jul 2020 15:08:08 +0900 Subject: [PATCH] Set default locale to US SimpleDateFormat will use the default locale value if not explicitly set. If the default locale is Arabic, SimpleDateFormat#format will return a string that does not conform to the given pattern. In ExifInterface, if setDateTime is called on a device with an Arabic locale, it will write a string value that will not follow the EXIF standard "YYYY:MM:DD HH:MM:SS" format. Thus, we need to set the locale to Locale.US at all times. Bug: 160674042 Test: N/A Change-Id: I2ad42f73742fd8ceeeeae47eafea69015f50814d --- media/java/android/media/ExifInterface.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java index 6d690f0aa3976..4a6724a09c1e7 100644 --- a/media/java/android/media/ExifInterface.java +++ b/media/java/android/media/ExifInterface.java @@ -1411,9 +1411,9 @@ public class ExifInterface { private static final int IMAGE_TYPE_WEBP = 14; static { - sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); + sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US); sFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); - sFormatterTz = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss XXX"); + sFormatterTz = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss XXX", Locale.US); sFormatterTz.setTimeZone(TimeZone.getTimeZone("UTC")); // Build up the hash tables to look up Exif tags for reading Exif tags.