Java Code Examples for java.text.DateFormatSymbols#getZoneStrings()
The following examples show how to use
java.text.DateFormatSymbols#getZoneStrings() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateFormatSymbolsTest.java From j2objc with Apache License 2.0 | 6 votes |
public void test_serialization() throws Exception { DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRANCE); String[][] zoneStrings = symbols.getZoneStrings(); assertNotNull(zoneStrings); // serialize ByteArrayOutputStream byteOStream = new ByteArrayOutputStream(); ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream); objectOStream.writeObject(symbols); // and deserialize ObjectInputStream objectIStream = new ObjectInputStream( new ByteArrayInputStream(byteOStream.toByteArray())); DateFormatSymbols symbolsD = (DateFormatSymbols) objectIStream .readObject(); String[][] zoneStringsD = symbolsD.getZoneStrings(); assertNotNull(zoneStringsD); assertEquals(symbols, symbolsD); }
Example 2
Source File: bug4117335.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN); String[] eras = symbols.getEras(); System.out.println("BC = " + eras[0]); if (!eras[0].equals(bc)) { System.out.println("*** Should have been " + bc); throw new Exception("Error in BC"); } System.out.println("AD = " + eras[1]); if (!eras[1].equals(ad)) { System.out.println("*** Should have been " + ad); throw new Exception("Error in AD"); } String[][] zones = symbols.getZoneStrings(); for (int i = 0; i < zones.length; i++) { if (!"Asia/Tokyo".equals(zones[i][0])) { continue; } System.out.println("Long zone name = " + zones[i][1]); if (!zones[i][1].equals(jstLong)) { System.out.println("*** Should have been " + jstLong); throw new Exception("Error in long TZ name"); } System.out.println("Short zone name = " + zones[i][2]); if (!zones[i][2].equals(jstShort)) { System.out.println("*** Should have been " + jstShort); throw new Exception("Error in short TZ name"); } System.out.println("Long zone name = " + zones[i][3]); if (!zones[i][3].equals(jdtLong)) { System.out.println("*** Should have been " + jdtLong); throw new Exception("Error in long TZ name"); } System.out.println("SHORT zone name = " + zones[i][4]); if (!zones[i][4].equals(jdtShort)) { System.out.println("*** Should have been " + jdtShort); throw new Exception("Error in short TZ name"); } } }
Example 3
Source File: bug4117335.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN); String[] eras = symbols.getEras(); System.out.println("BC = " + eras[0]); if (!eras[0].equals(bc)) { System.out.println("*** Should have been " + bc); throw new Exception("Error in BC"); } System.out.println("AD = " + eras[1]); if (!eras[1].equals(ad)) { System.out.println("*** Should have been " + ad); throw new Exception("Error in AD"); } String[][] zones = symbols.getZoneStrings(); for (int i = 0; i < zones.length; i++) { if (!"Asia/Tokyo".equals(zones[i][0])) { continue; } System.out.println("Long zone name = " + zones[i][1]); if (!zones[i][1].equals(jstLong)) { System.out.println("*** Should have been " + jstLong); throw new Exception("Error in long TZ name"); } System.out.println("Short zone name = " + zones[i][2]); if (!zones[i][2].equals(jstShort)) { System.out.println("*** Should have been " + jstShort); throw new Exception("Error in short TZ name"); } System.out.println("Long zone name = " + zones[i][3]); if (!zones[i][3].equals(jdtLong)) { System.out.println("*** Should have been " + jdtLong); throw new Exception("Error in long TZ name"); } System.out.println("SHORT zone name = " + zones[i][4]); if (!zones[i][4].equals(jdtShort)) { System.out.println("*** Should have been " + jdtShort); throw new Exception("Error in short TZ name"); } } }
Example 4
Source File: bug4117335.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN); String[] eras = symbols.getEras(); System.out.println("BC = " + eras[0]); if (!eras[0].equals(bc)) { System.out.println("*** Should have been " + bc); throw new Exception("Error in BC"); } System.out.println("AD = " + eras[1]); if (!eras[1].equals(ad)) { System.out.println("*** Should have been " + ad); throw new Exception("Error in AD"); } String[][] zones = symbols.getZoneStrings(); for (int i = 0; i < zones.length; i++) { if (!"Asia/Tokyo".equals(zones[i][0])) { continue; } System.out.println("Long zone name = " + zones[i][1]); if (!zones[i][1].equals(jstLong)) { System.out.println("*** Should have been " + jstLong); throw new Exception("Error in long TZ name"); } System.out.println("Short zone name = " + zones[i][2]); if (!zones[i][2].equals(jstShort)) { System.out.println("*** Should have been " + jstShort); throw new Exception("Error in short TZ name"); } System.out.println("Long zone name = " + zones[i][3]); if (!zones[i][3].equals(jdtLong)) { System.out.println("*** Should have been " + jdtLong); throw new Exception("Error in long TZ name"); } System.out.println("SHORT zone name = " + zones[i][4]); if (!zones[i][4].equals(jdtShort)) { System.out.println("*** Should have been " + jdtShort); throw new Exception("Error in short TZ name"); } } }
Example 5
Source File: bug4117335.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN); String[] eras = symbols.getEras(); System.out.println("BC = " + eras[0]); if (!eras[0].equals(bc)) { System.out.println("*** Should have been " + bc); throw new Exception("Error in BC"); } System.out.println("AD = " + eras[1]); if (!eras[1].equals(ad)) { System.out.println("*** Should have been " + ad); throw new Exception("Error in AD"); } String[][] zones = symbols.getZoneStrings(); for (int i = 0; i < zones.length; i++) { if (!"Asia/Tokyo".equals(zones[i][0])) { continue; } System.out.println("Long zone name = " + zones[i][1]); if (!zones[i][1].equals(jstLong)) { System.out.println("*** Should have been " + jstLong); throw new Exception("Error in long TZ name"); } System.out.println("Short zone name = " + zones[i][2]); if (!zones[i][2].equals(jstShort)) { System.out.println("*** Should have been " + jstShort); throw new Exception("Error in short TZ name"); } System.out.println("Long zone name = " + zones[i][3]); if (!zones[i][3].equals(jdtLong)) { System.out.println("*** Should have been " + jdtLong); throw new Exception("Error in long TZ name"); } System.out.println("SHORT zone name = " + zones[i][4]); if (!zones[i][4].equals(jdtShort)) { System.out.println("*** Should have been " + jdtShort); throw new Exception("Error in short TZ name"); } } }
Example 6
Source File: bug4117335.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN); String[] eras = symbols.getEras(); System.out.println("BC = " + eras[0]); if (!eras[0].equals(bc)) { System.out.println("*** Should have been " + bc); throw new Exception("Error in BC"); } System.out.println("AD = " + eras[1]); if (!eras[1].equals(ad)) { System.out.println("*** Should have been " + ad); throw new Exception("Error in AD"); } String[][] zones = symbols.getZoneStrings(); for (int i = 0; i < zones.length; i++) { if (!"Asia/Tokyo".equals(zones[i][0])) { continue; } System.out.println("Long zone name = " + zones[i][1]); if (!zones[i][1].equals(jstLong)) { System.out.println("*** Should have been " + jstLong); throw new Exception("Error in long TZ name"); } System.out.println("Short zone name = " + zones[i][2]); if (!zones[i][2].equals(jstShort)) { System.out.println("*** Should have been " + jstShort); throw new Exception("Error in short TZ name"); } System.out.println("Long zone name = " + zones[i][3]); if (!zones[i][3].equals(jdtLong)) { System.out.println("*** Should have been " + jdtLong); throw new Exception("Error in long TZ name"); } System.out.println("SHORT zone name = " + zones[i][4]); if (!zones[i][4].equals(jdtShort)) { System.out.println("*** Should have been " + jdtShort); throw new Exception("Error in short TZ name"); } } }
Example 7
Source File: ZoneNameProviderSPI.java From Time4A with Apache License 2.0 | 4 votes |
@Override public String getDisplayName( String tzid, NameStyle style, Locale locale ) { if (GMT_ZONES.contains(tzid)) { return ""; // falls back to canonical identifier (Z for ZonalOffset.UTC) } Map<String, Map<NameStyle, String>> map = NAMES.get(locale); if (map == null) { DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale); String[][] zoneNames = symbols.getZoneStrings(); map = new HashMap<String, Map<NameStyle, String>>(); for (String[] arr : zoneNames) { Map<NameStyle, String> names = new EnumMap<NameStyle, String>(NameStyle.class); names.put(NameStyle.LONG_STANDARD_TIME, arr[1]); names.put(NameStyle.SHORT_STANDARD_TIME, arr[2]); names.put(NameStyle.LONG_DAYLIGHT_TIME, arr[3]); names.put(NameStyle.SHORT_DAYLIGHT_TIME, arr[4]); // TODO: Wenn Daten verfügbar sind, dann hier einfügen (und NameStyle erweitern) map.put(arr[0], names); } Map<String, Map<NameStyle, String>> old = NAMES.putIfAbsent(locale, map); if (old != null) { map = old; } } Map<NameStyle, String> styledNames = map.get(tzid); if (styledNames != null) { return styledNames.get(style); } return ""; // ************************************************************************************* // OLD CODE // ************************************************************************************* // Timezone tz = Timezone.of("java.util.TimeZone~" + tzid, ZonalOffset.UTC); // // if (tz.isFixed() && tz.getOffset(Moment.UNIX_EPOCH).equals(ZonalOffset.UTC)) { // return ""; // } // // return tz.getDisplayName(style, locale); // ************************************************************************************* }