在使用Java Util日期发送日期时间戳时,如何阻止我的Android代码发送阿拉伯语文本?

发布于 2025-02-13 22:45:09 字数 1044 浏览 0 评论 0原文

在该应用程序中,我们正在尝试将遥测事件发送给我们的API,但伊朗的用户正在通过此类“ ۲۰۲۲-۰۷-۰۷-۰۶T۰۰:۰۳:۳۳..۳۹۰z”的时间戳发送。

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

以上是API返回的例外,将其设置为默认设置,但是我也无法通过使用下面的阿拉伯语语言环境来复制错误,

方法

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")
}

这是用于获取时间戳数据的 JSON字符串。下面的示例:

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

我们唯一拥有的信息是服务器上面的错误,并且该请求是在伊朗中提出的

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渡你暖光 2025-02-20 22:45:09

将其设置为环境。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文