Unify date truncation logic in PermissionChange code

Tests were intermittently failing because we were using Instant to
truncate the date which always assumes GMT time. Meanwhile, the date
instances we made would be in the default timezone.

Everything works fine when the devices stay in GMT but if they ever
changed, there would be a discrepancy causing the truncation to truncate
to GMT day borders which would not match the expected default timezone
borders.

We fix this by doing the same thing we do in the serialize logic,
truncating via the formatter itself, ensuring that we truncate at day
granularity for the test's expected timezone.

Bug: 235636205
Test: Change DuT timezone. atest PermissionChangeStorageImplTest
Change-Id: I5a445715a94b10b88b285970cda654a94edfca30
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/service/PermissionChangeStorageImpl.kt b/PermissionController/src/com/android/permissioncontroller/permission/service/PermissionChangeStorageImpl.kt
index df5d5a6..eac97fe 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/service/PermissionChangeStorageImpl.kt
+++ b/PermissionController/src/com/android/permissioncontroller/permission/service/PermissionChangeStorageImpl.kt
@@ -36,8 +36,6 @@
 import java.nio.charset.StandardCharsets
 import java.text.ParseException
 import java.text.SimpleDateFormat
-import java.time.Instant
-import java.time.temporal.ChronoUnit
 import java.util.Date
 import java.util.Locale
 
@@ -164,8 +162,7 @@
                 ?: throw IllegalArgumentException(
                     "Could not parse date $changeDate on package $packageName")
             if (truncateToDay) {
-                changeTime =
-                    Instant.ofEpochMilli(changeTime).truncatedTo(ChronoUnit.DAYS).toEpochMilli()
+                changeTime = dateFormat.parse(dateFormat.format(Date(changeTime))).time
             }
             change = PermissionChange(packageName, changeTime)
         } catch (e: XmlPullParserException) {