[RESOLVIDO]Ao gravar pegar Mes e ano do campo textfield Data

Estou pesquisando no fórum mas não consegui resolver o meu problema.

possuo esse código para gravar no BD.

[code]
String vSqlAdicionar = “INSERT INTO datamesano (fd_data, fd_mes, fd_ano) VALUES (default,?,?,?)”;
try {
Connection conn = Conexao.getConexao();
PreparedStatement pst = conn.prepareStatement(vSqlAdicionar);

        pst.setDate(1, Util.strToDate(txData.getText()));
        pst.setString(2, );  //mes
        pst.setString(3,);  //ano
        
        pst.executeUpdate();

        JOptionPane.showMessageDialog(null, "Adicionaoa com Sucesso!");
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Erro ao gravar registo\n" + ex.getMessage() + "\n" + ex.getCause());
    }[/code]

como devem ter notado utilizo uma classe UTIL para pegar o valor o jtextField e transformar em Date enviar pro BD. e ao contrario quando busca do BD.

o formato do jtextField é esse

txData.setText(new SimpleDateFormat(“dd/MM/yyyy”).format(new Date(System.currentTimeMillis())));

eu gostaria de quando executar esse comando, fazer com que seja pego apenas o Mês que esta no txDate e grave na posição 2, o mesmo pro Ano e gravar na posição 3.

agradeço a atenção

eu estou tentando achar uma solução

tentei da seguinte forma

[code]txData.setText(new SimpleDateFormat(“dd/MM/yyyy”).format(new Date(System.currentTimeMillis())));

    SimpleDateFormat formatIso = new SimpleDateFormat("dd-MM-yyyy");
    SimpleDateFormat formatOut = new SimpleDateFormat("MM");
    String dstr = txData.getText();
    Date data;
    try {
        data = formatIso.parse(dstr);
        System.out.println(formatOut.format(data));
    } catch (ParseException e) {
        e.printStackTrace();
    }[/code]

tive q alterar a importação

de

import java.sql.Date;
para

mas recebo o seguinte erro.

run: java.text.ParseException: Unparseable date: "16/10/2013" at java.text.DateFormat.parse(DateFormat.java:357) at Janelas.JFFuncionariosDespesas.<init>(JFFuncionariosDespesas.java:62) at Janelas.JFFuncionariosDespesas$17.run(JFFuncionariosDespesas.java:1248) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:682) at java.awt.EventQueue$3.run(EventQueue.java:680) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:691) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) CONSTRUÍDO COM SUCESSO (tempo total: 6 segundos)

aqui esta o erro

txData.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()))); SimpleDateFormat formatIso = new SimpleDateFormat("dd-MM-yyyy");

foi so deixar assim


SimpleDateFormat formatIso = new SimpleDateFormat("dd/MM/yyyy");

que funcionou.

mas igual tive q tirar o import sql.date por util.date

farei mais uns testes para ver se nao vai ocasionar problemas.