在使用Java Util日期发送日期时间戳时,如何阻止我的Android代码发送阿拉伯语文本?
在该应用程序中,我们正在尝试将遥测事件发送给我们的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其设置为环境。
Setting the Locale to Locale.ENGLISH solved the problem was just difficult to test without setting my device language to Arabic