Created
July 15, 2021 07:37
-
-
Save dmikurube/537d8823b3f3db7d7ada9eb81b252c42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Method; | |
import java.text.DateFormatSymbols; | |
import java.util.Arrays; | |
import java.util.Locale; | |
public final class TimeZoneNames { | |
public static void main(final String[] args) throws Exception { | |
final String[][] internal = getInternalZoneStrings(); | |
final String[][] standard = getStandardZoneStrings(); | |
System.out.printf("%d : %d\n", internal.length, standard.length); | |
if (internal.length == standard.length) { | |
for (int i = 0; i < internal.length; ++i) { | |
if (Arrays.equals(internal[i], standard[i])) { | |
System.out.println("true"); | |
print(internal[i]); | |
} else { | |
System.out.println("false"); | |
print(standard[i]); | |
print(internal[i]); | |
} | |
} | |
} | |
} | |
private static String[][] getInternalZoneStrings() throws Exception { | |
final Class<?> clazz = Class.forName("sun.util.locale.provider.TimeZoneNameUtility"); | |
final Method method = clazz.getMethod("getZoneStrings", Locale.class); | |
final Object zoneStringsObject = method.invoke(null, Locale.ENGLISH); | |
return (String[][]) zoneStringsObject; | |
} | |
private static String[][] getStandardZoneStrings() throws Exception { | |
final DateFormatSymbols symbols = DateFormatSymbols.getInstance(Locale.ROOT); | |
return symbols.getZoneStrings(); | |
} | |
private static void print(final String[] zoneStrings) { | |
System.out.printf(" ID: %s\n", zoneStrings[0]); | |
System.out.printf(" Long (standard): %s\n", zoneStrings[1]); | |
System.out.printf(" Short (standard): %s\n", zoneStrings[2]); | |
System.out.printf(" Long (daylight): %s\n", zoneStrings[3]); | |
System.out.printf(" Short (daylight): %s\n", zoneStrings[4]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment