RegionUtils { public static Region convertAvailabilityZone2Region(final String availabilityZone) { Region region; String regionStr = availabilityZone; String lastChar = availabilityZone.substring(availabilityZone.length() - 1, availabilityZone.length()); if (!NumberUtils.isDigits(lastChar)) { regionStr = availabilityZone.substring(0, availabilityZone.length() - 1); } region = Region.getRegion(Regions.valueOf(regionStr.replaceAll("-", "_").toUpperCase())); return region; } private  RegionUtils(); static Region convertAvailabilityZone2Region(final String availabilityZone); static Region convertLocationId2Region(final String locationId); static String convertAvailabilityZone2LocationId(final String availabilityZone);  }
@Test public void testConvertAvailabilityZone2Region() throws Exception { Region result; String availabilityZone1 = "us-east-1a"; result = RegionUtils.convertAvailabilityZone2Region(availabilityZone1); assertThat(result, is(Region.getRegion(Regions.US_EAST_1))); String availabilityZone2 = "eu-west-1"; result = RegionUtils.convertAvailabilityZone2Region(availabilityZone2); assertThat(result, is(Region.getRegion(Regions.EU_WEST_1))); }