类java.time.zone.ZoneRulesException源码实例Demo

下面列出了怎么用java.time.zone.ZoneRulesException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: TCKZoneIdSerialization.java
@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
    }
}
 
源代码2 项目: TencentKona-8   文件: TCKZoneIdSerialization.java
@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
    }
}
 
源代码3 项目: jdk8u60   文件: TCKZoneIdSerialization.java
@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
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: TCKZoneIdSerialization.java
@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
    }
}
 
@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
    }
}
 
源代码6 项目: openjdk-jdk9   文件: TCKZoneIdSerialization.java
@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
    }
}
 
源代码7 项目: jdk8u-jdk   文件: TCKZoneIdSerialization.java
@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
    }
}
 
@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());
}
 
源代码9 项目: jdk1.8-source-analysis   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码10 项目: dragonwell8_jdk   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码11 项目: aws-sdk-java-v2   文件: ZoneIdAttributeConverter.java
@Override
public ZoneId transformTo(AttributeValue input) {
    try {
        return STRING_CONVERTER.fromString(input.s());
    } catch (ZoneRulesException e) {
        throw new IllegalArgumentException(e);
    }
}
 
源代码12 项目: dragonwell8_jdk   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    if (zoneId.equals("FooLocation")) {
        return rules;
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码13 项目: dragonwell8_jdk   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    count++;
    if (zoneId.equals("DynamicLocation")) {
        return (forCaching ? null : (count > 2 ? ALTERNATE : BASE));
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码14 项目: dragonwell8_jdk   文件: TestZoneId.java
@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);
    }
}
 
源代码15 项目: TencentKona-8   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码16 项目: TencentKona-8   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    if (zoneId.equals("FooLocation")) {
        return rules;
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码17 项目: TencentKona-8   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    count++;
    if (zoneId.equals("DynamicLocation")) {
        return (forCaching ? null : (count > 2 ? ALTERNATE : BASE));
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码18 项目: TencentKona-8   文件: TestZoneId.java
@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);
    }
}
 
源代码19 项目: jdk8u60   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码20 项目: jdk8u60   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    if (zoneId.equals("FooLocation")) {
        return rules;
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码21 项目: jdk8u60   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    count++;
    if (zoneId.equals("DynamicLocation")) {
        return (forCaching ? null : (count > 2 ? ALTERNATE : BASE));
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码22 项目: jdk8u60   文件: TestZoneId.java
@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);
    }
}
 
源代码23 项目: JDKSourceCode1.8   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码24 项目: desugar_jdk_libs   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码25 项目: openjdk-jdk8u   文件: ZoneRegion.java
/**
 * 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);
}
 
源代码26 项目: openjdk-jdk8u   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    if (zoneId.equals("FooLocation")) {
        return rules;
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码27 项目: openjdk-jdk8u   文件: TCKZoneRulesProvider.java
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    count++;
    if (zoneId.equals("DynamicLocation")) {
        return (forCaching ? null : (count > 2 ? ALTERNATE : BASE));
    }
    throw new ZoneRulesException("Invalid");
}
 
源代码28 项目: openjdk-jdk8u   文件: TestZoneId.java
@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);
    }
}
 
源代码29 项目: openjdk-jdk8u-backup   文件: ZoneRegion.java
/**
 * 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);
}
 
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
    if (zoneId.equals("FooLocation")) {
        return rules;
    }
    throw new ZoneRulesException("Invalid");
}
 
 类所在包
 同包方法