RegionUtils { public static String convertAvailabilityZone2LocationId(final String availabilityZone) { String locationId = availabilityZone; String lastChar = availabilityZone.substring(availabilityZone.length() - 1, availabilityZone.length()); if (!NumberUtils.isDigits(lastChar)) { locationId = availabilityZone.substring(0, availabilityZone.length() - 1); } return locationId; } private  RegionUtils(); static Region convertAvailabilityZone2Region(final String availabilityZone); static Region convertLocationId2Region(final String locationId); static String convertAvailabilityZone2LocationId(final String availabilityZone);  }
@Test public void testConvertAvailabilityZone2LocationId() throws Exception { String result; String availabilityZone1 = "us-east-1a"; result = RegionUtils.convertAvailabilityZone2LocationId(availabilityZone1); assertThat(result, is("us-east-1")); String availabilityZone2 = "eu-west-1"; result = RegionUtils.convertAvailabilityZone2LocationId(availabilityZone2); assertThat(result, is("eu-west-1")); }