public static String bitcoinValueToFriendlyString(BigInteger value){
  boolean negative=value.compareTo(BigInteger.ZERO) < 0;
  if (negative)   value=value.negate();
  BigDecimal bd=new BigDecimal(value,8);
  String formatted=bd.toPlainString();
  int decimalPoint=formatted.indexOf(".");
  int toDelete=0;
  for (int i=formatted.length() - 1; i > decimalPoint + 2; i--) {
    if (formatted.charAt(i) == '0')     toDelete++;
 else     break;
  }
  return (negative ? "-" : "") + formatted.substring(0,formatted.length() - toDelete);
}

public static String bitcoinValueToFriendlyString ( BigInteger value ) { boolean negative = value . compareTo ( BigInteger . ZERO ) < 0 ; if ( negative ) value = value . negate ( ) ; BigDecimal bd = new BigDecimal ( value , 8 ) ; String formatted = bd . toPlainString ( ) ; int decimalPoint = formatted . indexOf ( "." ) ; int toDelete = 0 ; for ( int i = formatted . length ( ) - 1 ; i > decimalPoint + 2 ; i -- ) { if ( formatted . charAt ( i ) == '0' ) toDelete ++ ; else break ; } return ( negative ? "-" : "" ) + formatted . substring ( 0 , formatted . length ( ) - toDelete ) ; }
returns the given value in nanocoins as a 0 . 12 type string . more digits after the decimal place will be used if necessary , but two will always be present .
