google / google/j2objc

SimpleDateFormat uses numerals of system locale not the provided one

Open
#804 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6k
Forks
999
Avg merge
19h 20m
Merged PRs (30d)
14

Description

Hello guys.
Here's my problem:

``` objc
jlong timestamp = 1234500000;
NSString *formatString = @"yyyy-MM-dd'T'HH:mm:ss.SSS";

JavaUtilLocale *locale = new_JavaUtilLocale_initWithNSString_withNSString_(@"en", @"UK");
JavaTextDateFormat *dateFormat_ = new_JavaTextSimpleDateFormat_initWithNSString_withJavaUtilLocale_(formatString, locale);

NSString *result = [dateFormat_ formatWithJavaUtilDate:new_JavaUtilDate_initWithLong_(timestamp)];
```

The code above formats specified timestamp just right until it's Arabic locale that is used in iOS device settings. Then it's formatted with [Eastern Arabic Numerals](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals) and looks like this:

```
١٩٧٠-٠١-١٥T٠٩:٥٥:٠٠.٠٠٠
```

For whatever reason numerals are taken from current system locale not the provided one.
Please take a look at this. Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.