DecimalFormatクラスを調べます。あなたが望むのは次のようなものだと思います
DecimalFormat df = new DecimalFormat();
// By default, there will a locale specific thousands grouping.
// Remove the statement if you want thousands grouping.
// That is, for a number 12345, it is printed as 12,345 on my machine
// if I remove the following line.
df.setGroupingUsed(false);
// default is 3. Set whatever you think is good enough for you. 340 is max possible.
df.setMaximumFractionDigits(340);
df.setDecimalSeparatorAlwaysShown(false);
BigDecimal bd = new BigDecimal("1234.5678900000");
System.out.println(df.format(bd));
bd = new BigDecimal("1234.00");
System.out.println(df.format(bd));
Output:
1234.56789
1234
選択したRoundingModeを使用することもできます。DecimalFormatコンストラクターに提供されるパターンを使用して、表示する小数点の数を制御します。フォーマットの詳細については、DecimalFormatのドキュメントを参照してください。