MeasurementUnit { public static MeasurementUnit getFromLocale(Locale locale) { String countryCode = locale.getCountry(); ArrayList<String> countriesUsingImperial = new ArrayList<>(Arrays.asList(Locale.US.getCountry())); if (countriesUsingImperial.contains(countryCode)) { return Imperial; } return Metric; }  static MeasurementUnit getDefaultUnit(); static MeasurementUnit getFromLocale(Locale locale); static double convertCmToInch(double cm); static MeasurementUnit Imperial; static MeasurementUnit Metric; }
@Test public void getFromLocaleTest() throws Exception { assertEquals(MeasurementUnit.getFromLocale(Locale.US), MeasurementUnit.Imperial); assertEquals(MeasurementUnit.getFromLocale(Locale.JAPAN), MeasurementUnit.Metric); assertEquals(MeasurementUnit.getFromLocale(Locale.FRANCE), MeasurementUnit.Metric); }