when i am trying to insert date into the datefield of the oracle then date value are stored in to database but each date value are same like

DOB
01-JAN-70
01-JAN-70
01-JAN-70

public class practicdate {
JDateChooser dateChooser,dateChooser1;
practicdate(){
    dateChooser = new JDateChooser();
    dateChooser.setBounds(200, 200, 150, 20);
    getContentPane().add(dateChooser);
public void actionPerformed(ActionEvent e) {
java.util.Date utilDate=(java.util.Date) dateChooser.getDate();
java.sql.Date  sqlDate=new java.sql.Date(utilDate.getDate());
        try {
           java.sql.PreparedStatement ps=con.prepareStatement("insert into examdate values(?)");
           ps.setDate(1,new java.sql.Date(sqlDate.getDate()));
            ps.executeUpdate();
            ps.close();
            con.close();

        }

You can use new java.sql.Date(long milis) and getting the milliseconds from the selected date by using startDateDateChooser.getDate().getTime()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.