I'm trying to validate the txtServicoValor
field that receives a type BigDecimal
, follow my code, the validation is barring both the correct digits and the incorrect form, thank you for the help.
MaskFormatter mask = new MaskFormatter("###.###,#00.00");
JFormattedTextField campoTexto = new JFormattedTextField(mask);
mask.setValidCharacters("0123456789");
validos.install(campoTexto);
if(txtServico.getText().length() > 0
&& txtServicoValor.getText().length() > 0
&& (txtServicoValor.getText().replaceAll("\.", "").replace(",",".")).equals(campoTexto))
{
servico.setServico(txtServico.getText());
servico.setValorServico(new BigDecimal(txtServicoValor.getText().replaceAll("\.", "").replace(",",".")));
}