use of java.time.zone.ZoneRulesException in project jdk8u_jdk by JetBrains.
the class TCKZoneIdSerialization method test_deserialization_lenient_characters.
@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
}
}
use of java.time.zone.ZoneRulesException in project jdk8u_jdk by JetBrains.
the class ZoneRegion method ofId.
/**
* 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);
}
use of java.time.zone.ZoneRulesException in project j2objc by google.
the class ZoneRulesExceptionTest method test_constructor_message.
@Test
public void test_constructor_message() {
ZoneRulesException ex = new ZoneRulesException("message");
assertEquals("message", ex.getMessage());
assertNull(ex.getCause());
}
use of java.time.zone.ZoneRulesException in project Bytecoder by mirkosertic.
the class ZoneRegion method ofId.
/**
* 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);
}
use of java.time.zone.ZoneRulesException in project j2objc by google.
the class ZoneRulesExceptionTest method test_constructor_message_cause.
@Test
public void test_constructor_message_cause() {
Throwable cause = new Exception();
ZoneRulesException ex = new ZoneRulesException("message", cause);
assertEquals("message", ex.getMessage());
assertSame(cause, ex.getCause());
}
Aggregations