public static CurrencyValue parse(String externalVal,String defaultCurrency){
  if (externalVal == null) {
    return null;
  }
  String amount=externalVal;
  String code=defaultCurrency;
  if (externalVal.contains(",")) {
    String[] amountAndCode=externalVal.split(",");
    amount=amountAndCode[0];
    code=amountAndCode[1];
  }
  if (amount.equals("*")) {
    return null;
  }
  Currency currency=CurrencyField.getCurrency(code);
  if (currency == null) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Currency code not supported by this JVM: " + code);
  }
  try {
    double value=Double.parseDouble(amount);
    long currencyValue=Math.round(value * Math.pow(10.0,currency.getDefaultFractionDigits()));
    return new CurrencyValue(currencyValue,code);
  }
 catch (  NumberFormatException e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,e);
  }
}

public static CurrencyValue parse ( String externalVal , String defaultCurrency ) { if ( externalVal == null ) { return null ; } String amount = externalVal ; String code = defaultCurrency ; if ( externalVal . contains ( "," ) ) { String [ ] amountAndCode = externalVal . split ( "," ) ; amount = amountAndCode [ 0 ] ; code = amountAndCode [ 1 ] ; } if ( amount . equals ( "*" ) ) { return null ; } Currency currency = CurrencyField . getCurrency ( code ) ; if ( currency == null ) { throw new SolrException ( SolrException . ErrorCode . BAD_REQUEST , "Currency code not supported by this JVM: " + code ) ; } try { double value = Double . parseDouble ( amount ) ; long currencyValue = Math . round ( value * Math . pow ( 10.0 , currency . getDefaultFractionDigits ( ) ) ) ; return new CurrencyValue ( currencyValue , code ) ; } catch ( NumberFormatException e ) { throw new SolrException ( SolrException . ErrorCode . BAD_REQUEST , e ) ; } }
constructs a new currency value by parsing the specific input . < p / > currency values are expected to be in the format & lt ; amount & gt ; , & lt ; currency code & gt ; , for example , " 500 , usd " would represent 5 u . s . dollars . < p / > if no currency code is specified , the default is assumed .
