@Test public void testFormatBoleto() { String boleto = "00190000090302122300740963035171576320000010249"; assertEquals("00190.00009 03021.223007 40963.035171 5 76320000010249", service.format(boleto)); }
@Override public String format(String boleto) { boleto = SEPARATORS.matcher(boleto).replaceAll(""); StringBuilder builder = new StringBuilder(); builder.append(boleto.substring(0, 5)).append("."); builder.append(boleto.substring(5, 10)).append(" "); builder.append(boleto.substring(10, 15)).append("."); builder.append(boleto.substring(15, 21)).append(" "); builder.append(boleto.substring(21, 26)).append("."); builder.append(boleto.substring(26, 32)).append(" "); builder.append(boleto.substring(32, 33)).append(" "); builder.append(boleto.substring(33, boleto.length())); return builder.toString(); }
BoletoRegexValidatorService extends AbstractDocRegexValidatorService { @Override public String format(String boleto) { boleto = SEPARATORS.matcher(boleto).replaceAll(""); StringBuilder builder = new StringBuilder(); builder.append(boleto.substring(0, 5)).append("."); builder.append(boleto.substring(5, 10)).append(" "); builder.append(boleto.substring(10, 15)).append("."); builder.append(boleto.substring(15, 21)).append(" "); builder.append(boleto.substring(21, 26)).append("."); builder.append(boleto.substring(26, 32)).append(" "); builder.append(boleto.substring(32, 33)).append(" "); builder.append(boleto.substring(33, boleto.length())); return builder.toString(); } }
BoletoRegexValidatorService extends AbstractDocRegexValidatorService { @Override public String format(String boleto) { boleto = SEPARATORS.matcher(boleto).replaceAll(""); StringBuilder builder = new StringBuilder(); builder.append(boleto.substring(0, 5)).append("."); builder.append(boleto.substring(5, 10)).append(" "); builder.append(boleto.substring(10, 15)).append("."); builder.append(boleto.substring(15, 21)).append(" "); builder.append(boleto.substring(21, 26)).append("."); builder.append(boleto.substring(26, 32)).append(" "); builder.append(boleto.substring(32, 33)).append(" "); builder.append(boleto.substring(33, boleto.length())); return builder.toString(); }  }
BoletoRegexValidatorService extends AbstractDocRegexValidatorService { @Override public String format(String boleto) { boleto = SEPARATORS.matcher(boleto).replaceAll(""); StringBuilder builder = new StringBuilder(); builder.append(boleto.substring(0, 5)).append("."); builder.append(boleto.substring(5, 10)).append(" "); builder.append(boleto.substring(10, 15)).append("."); builder.append(boleto.substring(15, 21)).append(" "); builder.append(boleto.substring(21, 26)).append("."); builder.append(boleto.substring(26, 32)).append(" "); builder.append(boleto.substring(32, 33)).append(" "); builder.append(boleto.substring(33, boleto.length())); return builder.toString(); }  @Override String format(String boleto); @Override boolean validate(String boleto); @Override List<String> getRegexNames(); }
BoletoRegexValidatorService extends AbstractDocRegexValidatorService { @Override public String format(String boleto) { boleto = SEPARATORS.matcher(boleto).replaceAll(""); StringBuilder builder = new StringBuilder(); builder.append(boleto.substring(0, 5)).append("."); builder.append(boleto.substring(5, 10)).append(" "); builder.append(boleto.substring(10, 15)).append("."); builder.append(boleto.substring(15, 21)).append(" "); builder.append(boleto.substring(21, 26)).append("."); builder.append(boleto.substring(26, 32)).append(" "); builder.append(boleto.substring(32, 33)).append(" "); builder.append(boleto.substring(33, boleto.length())); return builder.toString(); }  @Override String format(String boleto); @Override boolean validate(String boleto); @Override List<String> getRegexNames();  }