I'm making a program that will generate the dates between two dates. The dates are from a DateChooser
. When I click a button the dates between the two dates is generated like this :
date1 Jun 5, 2013
date2 June 20, 2013
Using this code
Calendar cal2 = Calendar.getInstance();
cal2.setTime(toDate);
while (cal2.getTime().before(newDateString)) {
cal2.add(Calendar.DATE, 1);
String datelist=(format.format(cal2.getTime()));
System.out.println(datelist);
It will generate this output
2013-06-18
2013-06-19
2013-06-20
2013-06-21
2013-06-22
2013-06-23
2013-06-24
2013-06-25
2013-06-26
2013-06-27
2013-06-28
2013-06-29
2013-06-30
2013-07-01
2013-07-02
My problem here is that I want to output this on a JTable
. I tried calling each string
from the datelist
like this System.out.println(arrayImageList.get(2));
but it didn't work. How can I output datelist
to JTable
or call every element from datelist
individually?
final String oldy= ("yyyy-MM-dd");
final String newy = ("MMMM dd, yyyy");
SimpleDateFormat formatty = new SimpleDateFormat(oldy);
java.util.Date datey=null;
//format the final date output to MMMM-dd-yyyy
try {
datey=formatty.parse(datelist);
java.util.Date newqwe2 = new SimpleDateFormat(oldy).parse(datelist);
String eqweqwe = new SimpleDateFormat(newy).format(newqwe2);
ArrayList<String> arrayImageList = new ArrayList<String>();
List<String> strlist2 = new ArrayList<String>();
arrayImageList.addAll((List<String>) Arrays.asList(eqweqwe));
for(int i = 0; i < arrayImageList.size(); i++){
strlist2.add(arrayImageList.get(i));
System.out.println(strlist2.get(2));
Sorry for the long post but I just want you guys to get whole process in case there is something missing.