java.time.zone.ZoneRulesException Java Examples
The following examples show how to use
java.time.zone.ZoneRulesException.
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: TCKZoneIdSerialization.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #2
Source File: TCKZoneIdSerialization.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #3
Source File: TCKZoneIdSerialization.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #4
Source File: TCKZoneIdSerialization.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #5
Source File: TCKZoneIdSerialization.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #6
Source File: TCKZoneIdSerialization.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #7
Source File: TCKZoneIdSerialization.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_deserialization_lenient_characters() throws Exception { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); assertEquals(deser, deser); assertEquals(deser.hashCode(), deser.hashCode()); assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); fail(); } catch (ZoneRulesException ex) { // expected } }
Example #8
Source File: TestZoneId.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(expectedExceptions = ZoneRulesException.class) public void test_systemDefault_unableToConvert_unknownId() { TimeZone current = TimeZone.getDefault(); try { TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); ZoneId.systemDefault(); } finally { TimeZone.setDefault(current); } }
Example #9
Source File: ZoneRegion.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #10
Source File: TCKZoneRulesProvider.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { count++; if (zoneId.equals("DynamicLocation")) { return (forCaching ? null : (count > 2 ? ALTERNATE : BASE)); } throw new ZoneRulesException("Invalid"); }
Example #11
Source File: TCKZoneRulesProvider.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { if (zoneId.equals("FooLocation")) { return rules; } throw new ZoneRulesException("Invalid"); }
Example #12
Source File: TCKZoneRulesProvider.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { if (zoneId.equals("FooLocation")) { return rules; } throw new ZoneRulesException("Invalid"); }
Example #13
Source File: TCKZoneRulesProvider.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { if (zoneId.equals("FooLocation")) { return rules; } throw new ZoneRulesException("Invalid"); }
Example #14
Source File: TCKZoneRulesProvider.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { count++; if (zoneId.equals("DynamicLocation")) { return (forCaching ? null : (count > 2 ? ALTERNATE : BASE)); } throw new ZoneRulesException("Invalid"); }
Example #15
Source File: ZoneRegion.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #16
Source File: TestZoneId.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(expectedExceptions = ZoneRulesException.class) public void test_systemDefault_unableToConvert_unknownId() { TimeZone current = TimeZone.getDefault(); try { TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); ZoneId.systemDefault(); } finally { TimeZone.setDefault(current); } }
Example #17
Source File: ZoneRegion.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #18
Source File: TCKZoneRulesProvider.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { count++; if (zoneId.equals("DynamicLocation")) { return (forCaching ? null : (count > 2 ? ALTERNATE : BASE)); } throw new ZoneRulesException("Invalid"); }
Example #19
Source File: ZoneRegion.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #20
Source File: ZoneRegion.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #21
Source File: TzdbZoneRulesProvider.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public ZoneRules getZoneRules(String zoneId) { Object obj = zones.get(zoneId); if (obj == null) { String zoneId0 = zoneId; if (links.containsKey(zoneId)) { zoneId = links.get(zoneId); obj = zones.get(zoneId); } if (obj == null) { // Timezone link can be located in 'backward' file and it // can refer to another link, so we need to check for // link one more time, before throwing an exception String zoneIdBack = zoneId; if (links.containsKey(zoneId)) { zoneId = links.get(zoneId); obj = zones.get(zoneId); } if (obj == null) { throw new ZoneRulesException("Unknown time-zone ID: " + zoneIdBack); } } } if (obj instanceof ZoneRules) { return (ZoneRules)obj; } try { ZoneRules zrules = buildRules(zoneId, (List<ZoneLine>)obj); zones.put(zoneId, zrules); return zrules; } catch (Exception ex) { throw new ZoneRulesException( "Invalid binary time-zone data: TZDB:" + zoneId, ex); } }
Example #22
Source File: TzdbZoneRulesProvider.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Creates an instance. * * @throws ZoneRulesException if unable to load */ public TzdbZoneRulesProvider(List<Path> files) { try { load(files); } catch (Exception ex) { throw new ZoneRulesException("Unable to load TZDB time-zone rules", ex); } }
Example #23
Source File: ZoneRegion.java From desugar_jdk_libs with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #24
Source File: ZoneRegion.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #25
Source File: ZoneRegion.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #26
Source File: FormatDateExpressionProcessorTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testExecuteIncorrectTimeZoneId() { ZoneRulesException exception = assertThrows(ZoneRulesException.class, () -> processor.execute("formatDate(1994-11-05T08:15:30Z, yyyy-MM-dd'T'HH:mm:ssXXX, Incorrect)")); assertEquals("Unknown time-zone ID: Incorrect", exception.getMessage()); }
Example #27
Source File: TestZoneId.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(expectedExceptions = ZoneRulesException.class) public void test_systemDefault_unableToConvert_unknownId() { TimeZone current = TimeZone.getDefault(); try { TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); ZoneId.systemDefault(); } finally { TimeZone.setDefault(current); } }
Example #28
Source File: ZoneRegion.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
Example #29
Source File: TCKZoneRulesProvider.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected ZoneRules provideRules(String zoneId, boolean forCaching) { count++; if (zoneId.equals("DynamicLocation")) { return (forCaching ? null : (count > 2 ? ALTERNATE : BASE)); } throw new ZoneRulesException("Invalid"); }
Example #30
Source File: TestZoneId.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(expectedExceptions = ZoneRulesException.class) public void test_systemDefault_unableToConvert_unknownId() { TimeZone current = TimeZone.getDefault(); try { TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); ZoneId.systemDefault(); } finally { TimeZone.setDefault(current); } }