public void testStringToNumberLocale(){
  Locale defaultLocale=Locale.getDefault();
  Locale.setDefault(Locale.US);
  NumberConverter converter=makeConverter();
  converter.setUseLocaleFormat(true);
  assertEquals("Default Locale " + numbers[0],numbers[0],converter.convert(getExpectedType(),"-0,012"));
  assertEquals("Default Locale " + numbers[1],numbers[1],converter.convert(getExpectedType(),"0,013"));
  try {
    converter.convert(getExpectedType(),"0,02x");
    fail("Expected invalid value to cause ConversionException");
  }
 catch (  Exception e) {
  }
  converter.setLocale(Locale.GERMAN);
  assertEquals("Locale.GERMAN " + numbers[2],numbers[2],converter.convert(getExpectedType(),"-0.022"));
  assertEquals("Locale.GERMAN " + numbers[3],numbers[3],converter.convert(getExpectedType(),"0.023"));
  try {
    converter.convert(getExpectedType(),"0.02x");
    fail("Expected invalid value to cause ConversionException");
  }
 catch (  Exception e) {
  }
  Locale.setDefault(defaultLocale);
}

public void testStringToNumberLocale ( ) { Locale defaultLocale = Locale . getDefault ( ) ; Locale . setDefault ( Locale . US ) ; NumberConverter converter = makeConverter ( ) ; converter . setUseLocaleFormat ( true ) ; assertEquals ( "Default Locale " + numbers [ 0 ] , numbers [ 0 ] , converter . convert ( getExpectedType ( ) , "-0,012" ) ) ; assertEquals ( "Default Locale " + numbers [ 1 ] , numbers [ 1 ] , converter . convert ( getExpectedType ( ) , "0,013" ) ) ; try { converter . convert ( getExpectedType ( ) , "0,02x" ) ; fail ( "Expected invalid value to cause ConversionException" ) ; } catch ( Exception e ) { } converter . setLocale ( Locale . GERMAN ) ; assertEquals ( "Locale.GERMAN " + numbers [ 2 ] , numbers [ 2 ] , converter . convert ( getExpectedType ( ) , "-0.022" ) ) ; assertEquals ( "Locale.GERMAN " + numbers [ 3 ] , numbers [ 3 ] , converter . convert ( getExpectedType ( ) , "0.023" ) ) ; try { converter . convert ( getExpectedType ( ) , "0.02x" ) ; fail ( "Expected invalid value to cause ConversionException" ) ; } catch ( Exception e ) { } Locale . setDefault ( defaultLocale ) ; }
convert string - - > number ( using default and specified locales )
