tl;dr
You cannot reliably determine a time zone from an offset. Your question is illogical.
Details
timeZoneId = "UTC+01:00
No, that is not a time zone. That is merely an offset.
- An offset is a number of hours-minutes-seconds ahead or behind the temporal prime meridian of UTC/GMT. Simply a number, nothing more.
- A time zone is much more. A time zone is a named history of the past, present, and future changes to the offset used by the people of a particular region, as decided by their politicians. A time zone has a name in format of
Continent/Region
such as Asia/Tokyo
or Africa/Tunis
.
Based on that I need to set correct timeZone in Java.
Not possible. Many time zones may share the same offset.
Take your example of +01:00. Many time zones may share that offset. These include Africa/Casablanca, Africa/Algiers, Africa/Ndjamena, Africa/Lagos, Europe/Brussels, Europe/Andorra, Europe/Malta, Europe/Oslo, Europe/Paris, and many more.
So an offset does not map to a time zone one-to-one.
Furthermore, the offset used by a time zone varies over time. This happens for various reasons. An invading army may dictate a certain time zone in its occupied territory. A politician may change the time zone of their jurisdiction to annoy or appease a neighboring country. Or some loopy politicians may decide to require their citizens go to bed an hour earlier or open their shops an hour later, in a practice known as Daylight Saving Time (DST).
The offset changing in a locality over time means that you cannot determine the offset in effect without specifying a date and time along with the name of a time zone.
Ideally it should set timezone of CET
No, CET
is not a time zone. Such 2-4 letter abbreviations are pseudo zones that hint at a time zone, and indicate whether Daylight Saving Time (DST) is in effect or not. But these pseudo-zones are not standardized, and are not even unique. Avoid them. Use real time zones with names of Continent/Region
.
Does anyone know how to achieve this?
If you mean “How to achieve determining a time zone from a given offset?”, you cannot. That is not possible as discussed above.
Can we some how convert UTC to GMT
UTC and GMT are the same thing when speaking practically, in common business contexts. The difference is less than a second.
All of this has been discussed many times on Stack Overflow. Search to learn more.