Reputation: 141
We have [GetServerTimeZoneInformation] used defined function in MS SQL Server which returns DaylightName or StandardName, ActiveTimeBias, Bias, DaylightBias, IsDST It uses Windows registry key to get these information but I have to write the code where linux(CentOs) operating system is being used and I have to get these information using Java. What is the Java API available which can give these values?
Upvotes: 0
Views: 276
Reputation: 111259
The TimeZone class gives you access to all or most of these data, for example:
TimeZone tz = TimeZone.getDefault();
String daylightName = tz.getDisplayName(true, TimeZone.LONG);
String standardName = tz.getDisplayName(false, TimeZone.LONG);
int rawOffset = tz.getRawOffset();
int daylightOffset = tz.getDSTSavings();
boolean isInDSTNow = tz.inDaylightTime(new Date());
Note however, that Java uses its own version of tzdb
, and not the system-wide installed tzdb, so there may be differences between what Java reports and what you would get from native operating system tools, especially for time zones that have been changed recently.
Upvotes: 1