0
I have this code that validates the dates of a card and puts in the table:
@SuppressWarnings("nls")
public static ObservableList<String> getPagaVenci1(TableView<PersonC> jtc, String sq4, int l) throws Exception{
Label le = new Label(sq4);
String g = le.getText();
ObservableList<String> data = FXCollections.observableArrayList();
Date datavs = new Date();
DateFormat f = DateFormat.getDateInstance();
f = DateFormat.getDateInstance();
System.out.println(f.format(datavs));
String datat = f.format(datavs);
String datav = datat;
String dataFormat = g;
int dasf;
int dasv;
String dataF = (String) dataFormat.subSequence(0,10);
int len = sq4.length();
int lo = l;
while(lo != 0){
switch(len){
case 22:
String dataF1 = (String) dataFormat.subSequence(12,22);
if(len == 22){
System.out.println("22");
dasf = Integer.parseInt(dataF.replace("/", "").toString());
dasv = Integer.parseInt(datav.replace("/", "").toString());
String sd7 = "";
String sd8 = "";
if(dasf <= dasv){
sd7 = dataF;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
dasf = Integer.parseInt(dataF1.replace("/", "").toString());
if(dasf <= dasv){
sd8 = dataF1;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
String[] sdarr3 = {sd7,sd8};
System.out.println(sdarr3);
data.addAll(sdarr3);
}
case 34:
String dataF11 = (String) dataFormat.subSequence(12,22);
String dataF2 = (String) dataFormat.subSequence(24,34);
if(sq4.length() == 34){
System.out.println("34");
dasf = Integer.parseInt(dataF.replace("/", "").toString());
dasv = Integer.parseInt(datav.replace("/", "").toString());
String sd4 = "";
String sd5 = "";
String sd6 = "";
if(dasf <= dasv){
sd4 = dataF;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
dasf = Integer.parseInt(dataF11.replace("/", "").toString());
if(dasf <= dasv){
sd5 = dataF11;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
dasf = Integer.parseInt(dataF2.replace("/", "").toString());
if(dasf <= dasv){
sd6 = dataF2;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
String[] sdarry2 = {sd4,sd5,sd6};
System.out.println(sdarry2);
data.addAll(sdarry2);
}
case 42:
String dataF111 = (String) dataFormat.subSequence(12,22);
String dataF22 = (String) dataFormat.subSequence(24,34);
if(sq4.length() == 42){
System.out.println("42");
dasf = Integer.parseInt(dataF.replace("/", "").toString());
dasv = Integer.parseInt(datav.replace("/", "").toString());
String sd = "";
String sd1 = "";
String sd2 = "";
String sd3 = "";
if(dasf <= dasv){
sd = dataF;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
dasf = Integer.parseInt(dataF111.replace("/", "").toString());
if(dasf <= dasv){
sd1 = dataF111;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
dasf = Integer.parseInt(dataF22.replace("/", "").toString());
if(dasf <= dasv){
sd2 = dataF22;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
String dataF3 = (String) dataFormat.subSequence(34,42);
dasf = Integer.parseInt(dataF3.replace("/", "").toString());
if(dasf <= dasv){
sd3 = dataF3;
System.out.println(sq4);
System.out.println("Encontrou o true.");
}
String[] sdarry = {sd,sd1,sd2,sd3};
System.out.println(sdarry);
data.addAll(sdarry);
}
lo = 0;
}
}
System.out.println(data);
return data;
}
I’m trying to slow it down. And there’s nothing on the table either.
What I do?
Code of Table Rows:
static ObservableList<Person> data = FXCollections.observableArrayList();
public static ObservableList<Person> SCs() {
String sql = "SELECT NOME,DIVIDA,PAGAMENTO,DATADV FROM CLIENTES";
String url = "Jdbc:oracle:thin:@localhost:1521:xe";
try(Connection con = DriverManager.getConnection(url, "system", "AL0921069LUCASJL");
PreparedStatement stm = con.prepareStatement(sql);
ResultSet rs = stm.executeQuery()){
int linha = 0;
while(rs.next()){
linha ++;
int l = linha;
System.out.println(l);
String sq1 = rs.getString("NOME");
String sq2 = rs.getString("DIVIDA");
String sq3 = rs.getString("PAGAMENTO");
String sq4 = rs.getString("DATADV");
data.addAll(new Person(sq1,sq2,sq3,Person.getPagaVenci(jtc,sq4,l)));
}
}catch(Exception es){
es.printStackTrace();
System.out.println("OK!");
SI.createExceptionDialog(es, "Erro Inesperado. \n"+ "Informe ao Fornecedor. \n"+ "Erro 5.");
}
return data;
}
Where and how do you call this function? What can come in the parameters
sq4
andl
?– Victor Stafusa
I updated the question.
– lucas daniel
Okay, I’m already trying to work out an answer.
– Victor Stafusa
Which strings exactly exist within the column
DATADV
? I ask this because I’m thinking there’s something wrong with the sizes you pass to thesubSequence
.– Victor Stafusa