può andar bene?
codice:
System.out.printf("%1.2g", x);