Home > front end >  How do I stop my Android code from sending Arabic text when sending a date timestamp using the Java
How do I stop my Android code from sending Arabic text when sending a date timestamp using the Java

Time:07-12

In the app we are trying to send telemetry events to our API but users in Iran are sending through the timestamp formatted as such "۲۰۲۲-۰۷-۰۶T۰۰:۰۳:۳۳.۳۹۰Z".

Exception while executing function:
LogTelemetry Could not convert string to DateTimeOffset: ۲۰۲۲-۰۷-۰۶T۰۰:۰۳:۳۳.۳۹۰Z.
Path 'appTimestamp', line 1, position 54.

The above is the exception the API is returning, the Locale is set to the Default, but I also have not been able to replicate the error by using the Arabic Locale

Below is the method used to get the timestamp

fun getGMTTImeStamp(): String {
    val formatter2 = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.getDefault())
    formatter2.timeZone = TimeZone.getTimeZone("GMT")
    val date = Date()
    return (formatter2.format(date)   "Z")
}

The data is being sent as a Json String. Example below:

{   
    "action":6,
    "appTimestamp":"2022-07-08T08:36:45.454Z",
    "deviceId":"6d0ae55186cd5efc",
    "origin":3,
    "originId":"3c945925-53ac-4fbe-9266-210410903a85",
    "platform":0
}

The only information we have is the error above from the server and that the request was made in Iran

CodePudding user response:

Setting the Locale to Locale.ENGLISH solved the problem was just difficult to test without setting my device language to Arabic

  • Related