Just answering the title question, "does System.currentTimeMillis() return UTC time?" ...
Yes. The Java API documentation actually says it's UTC:
currentTimeMillis
...
Returns: the difference, measured in milliseconds, between the current time and
midnight, January 1, 1970 UTC.
^^^
Although I do have slight doubts which might be why this question hasn't been answered so directly.
The currentTimeMillis() value is derived from the hardware clock on the system board powered by a battery. The actual value can be set to anything but the only really sane thing to do is to set it to the EPOCH relative to UTC so that the device is not bound to a particular timezone (devices frequently travel and transmit data across timezones).
However, the hardware clock can be changed and in the past it was not uncommon for it to be set to local time. I'm sure there are reasons for people to still use local time today.
If you happen to be using Linux you can check to see if your machine's hardware clock is using local time or UTC:
# timedatectl
Local time: Sat 2023-06-17 11:34:51 EDT
Universal time: Sat 2023-06-17 15:34:51 UTC
RTC time: Sat 2023-06-17 15:34:51
Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
^^
I don't know if there is a scenario where currentTimeMillis() would return the a local time based value if the hardware clock was set to a local TZ. My feel is that the operating system abstracts these things and Java just asks the OS. So if System.currentTimeMillis() does not return a UTC value, it's because the OS is not configured correctly.
So for most intents and purposes, yes, System.currentTimeMillis()
should return the same value across time zones (minus the usual drift, leap seconds, ...).