Always specify Locale for SimpleDateFormat!
If Locale is not specified, SimpleDateFormat may be converted depending on the locale of the terminal. If it is a Middle Eastern country, it may have adopted a system called "Indian numerals" [^ 1]. Then, "20181004083133657" will be converted to "٢٠١٨١٠٠٤٠٨٣١٣٣٦٥٧".
Always specify Locale.US
!
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS", Locale.US);
By the way, if you set the locale to new Locale ("ar", "EG")
, this phenomenon can be reproduced on the Android device, but for some reason it could not be reproduced on macOS.
[^ 1]: [Indian Numerals-Wikipedia](https://ja.wikipedia.org/wiki/%E3%82%A4%E3%83%B3%E3%83%89%E6%95%B0%E5 % AD% 97)
Recommended Posts