java - How change formate date from jDateChooser? -


i want enter start date , deadline task in database. format saves database this: tue apr 15 13:46:38 bst 2014 want in yyyy-mm-dd format.

this code use write data in database:

public void addtask() {     try {         taskt1 = new task();         t1.setidtask(jtidtask.gettext());         t1.setdesctask(jtdesctask.gettext());         t1.setdate(jdatechooserdare.getdate().tostring());         t1.setdeadline(jdatechooserdeadline.getdate().tostring());           taskdao dao = new taskdao();         dao.task(t1);      } catch (sqlexception ex) {         logger.getlogger(jttask.class.getname()).log(level.severe, null, ex);     } } 

--------------form-----------

enter image description here

thank help, hope explain best possible

greetings

i hope , can use simpledateformat accomplishing this.

code:

simpledateformat sdf = new simpledateformat("yyyy-mm-dd");

string date = sdf.format(jdatechooserdeadline.getdate());

t1.setdate(date);


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -