My frontend is java and backend (database) is sqlite.
When I select date from JDateChooser, I want to store date and time like this:
Saturday, January 17, 2015 3:44:12 PM
So how do I do this ?
I don't know what value I should write in the dateFormatString property of jDateChooser so as to get my above formatted date and time.
I have four columns in the table. One column name is "Date" and its datatype is DATETIME.
In this column i want to store above formatted date and time.
For date and time insertion, I wrote the following code:
try
{ String sql = "insert into tbexpense (`No.`, Subject_expense, Cost, Date) values (?, ?, ?, ?)";
pst = conn.prepareStatement(sql);
pst.setString(1, txtNo.getText());
pst.setString(2, txtexpense.getText());
pst.setString(3, txtcost.getText());
pst.setString(4, ((JTextField)jDateChooser1.getDateEditor().getUiComponent()).getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Saved.");
Update_table();
}
catch(Exception e)
{ JOptionPane.showMessageDialog(null, e);
}
YYYY-MM-DD HH:MM:SS. Read this documentation for more information.DateTimeformat won't accept that.