SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
            Date date = sdf.parse(d);
            Calendar cal = GregorianCalendar.getInstance();
            cal.setTime(date);

            for (i=0;x>i;i++){

            cal.add(GregorianCalendar.DATE, 7);
            String t = sdf.format(cal.getTime());
            DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
            model.addRow(new Object[]{t,c});
            }

Recommended Answers

All 3 Replies

Two comments.

  1. I look at your title then your code and back to the title and don't see any sign of what database you want to use as well as #2.
  2. In short, "Code Incomplete." Let me pick on line 6. What is x? I don't see it. It's like someone through some random lines together and well, I don't want to upset you here.

Read https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question

Now fill in those blanks.

it boils down to this:

step 1a: learn to read data from a JTable (which is not an array, just so you know)
step 1b: write the code that does so

step 2a: learn to write data into a DB
step 2b: write the code that does so

step 3: combine the code from 1b and 2b

In addition to what stultuske has said, you can use t and c directly because they are the content of the JTable row.

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.