I’m trying to get the date pattern of the device in my game. I changed my date pattern to month/day/year in the phone’s settings and the code down below gave me “MM/dd/yyyy” log. Then I changed my date pattern to day/month/year but still the log is “MM/dd/yyyy”. How can I get the date format in Android?
I’m using a class in the System.Globalization library
No idea what System.Globalization is connected to on Android, but I would try and isolate that first, perhaps by querying its status and showing that in your app.
I’m also not sure if System.DateTime respects or is connected to any of that, or if you have to connect it manually.
Finally, it’s possible something like this is only observed when the APK is launched, so if you are testing make sure you force-close the app between settings changes.
I haven’t messed with date format localization, but I just want to say make sure you are trying this with a build instead of Unity Remote. A build runs on the device. Unity Remote runs in the Editor but outputs on the device. I’d assume when you query the date format in Unity Remote that you’d get your desktop’s date format. (haven’t tried it, but it is my first guess)
I tried that. I closed the APK and went to settings and changed it. When I relaunched my game, I read the same thing on logcat. I even tried restarting the phone.
I suppose you could write a native plugin to report it back, or else perhaps use the AndroidJavaObject class in Unity to get at what you need on the Android side.