Code example for DecimalFormat

Methods: setRoundingMode

0
public class Geo extends Activity implements LocationListener {
 
  private LocationManager locationManager;
  private android.location.Location bestLocation;
  private boolean locating = false;
  private DecimalFormat decimalFormat = new DecimalFormat("#.####");
 
  public Geo() { 
    // this causes an issue on some devices, odd... 
    try { 
      this.decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
    } catch (java.lang.NoSuchMethodError e) {
      Log.w("Geo", "Exception: " + e.getMessage());
    } 
  } 
 
  @Override 
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState);