I want to keep only the number before dot, what comes after I don't want to. For example:
double x = 5.6
int y = 5 // the part before dot
For this purpose I have the following code:
SeekBar tipSeekBar;
EditText tipAmountET;
double tipAmount;
tipAmount = (tipSeekBar.getProgress()) * .01;
NumberFormat format = NumberFormat.getInstance(Locale.US);
Number number;
number = format.parse(String.valueOf(tipAmount));
double d = number.doubleValue();
String resultado = String.valueOf(d * 100);
tipAmountET.setText(resultado);
I tried to use the split on resultado
, but it gives me the exception ArrayOutOfBoundsException
. Like this, before the last line:
String[] split = resultado.split(".");
tipAmountET.setText(split[0]);