-1
How to convert a component JTextField
for type Date
? How to do research?
How to create a query for the bank by returning a list of orders according to a date range?
Follows the code currently used:
if (opcaoBusca.getSelectedIndex() == 0) {
JOptionPane.showMessageDialog(null,
"Escolha uma Opção de Busca!");
} else if (opcaoBusca.getSelectedIndex() == 1) {
RS = stmt.executeQuery("select numped FROM PCPEDC WHERE DATA > '10/01/2014' and numped = " + BuscaCodigo);
while (RS.next()) {
int Num = RS.getInt("numped");
consulta = false;
JOptionPane.showMessageDialog(null, "Dados Encontrado!!!!");
}
} else if (opcaoBusca.getSelectedIndex() == 2) {
RS = stmt.executeQuery("SELECT Data FROM PCPEDC WHERE Data BETWEEN " + Dtincial + "AND" + Dtfinal);
while (RS.next()) {
int Num = RS.getInt("numped");
//...
}
}
//mascara para os campos //
Dtincial = new JFormattedTextField(DateFormat.getDateInstance( ));
try {
javax.swing.text.MaskFormatter data= new javax.swing.text.MaskFormatter("##/##/####");
Dtincial = new javax.swing.JFormattedTextField(data);
} catch (Exception e){
}
Dtincial.setColumns(10);
Dtfinal = new JFormattedTextField(DateFormat.getDateInstance( ));
try {
javax.swing.text.MaskFormatter data= new javax.swing.text.MaskFormatter("##/##/####");
Dtfinal = new javax.swing.JFormattedTextField(data);
} catch (Exception e){
}
//declaração dos atributos
private JTextField Dtincial;
private JTextField Dtfinal;
Sorry guy but I didn’t understand this process, I did similar thing to this and it didn’t work
– Wesley Costa
I’ll put a code up here
– Wesley Costa
more in the case when setting the date it is giving error, like this: ps.setDate(1, Dtincial); ps.setDate(2, Dtfinal);
– Wesley Costa
someone to help?
– Wesley Costa
You’re looking to pass one
JFormattedTextField
for a method that receives aDate
, will give even error. You have to catch the value of the textfield and not the object.– Renan Gomes