而并没有进行比较!!! --我后面的代码是干什么的? while (rs.next()) { Date work = rs.getDate("date"); temp.setTime(date); if (temp.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) continue; int offset = temp.get(Calendar.DATE) - start.get(Calendar.DATE); if (offset > size) continue; else flag[offset]=true; } for (int i=0; i<flag.length; i++) { if (!flag[i]) { start.add(Calendar.DATE, i); System.out.println(start.getTime()); start.add(Calendar.DATE, -i); } }
我知道,但是还是有很多重复输出!!! --Like what? 你自己有没有试过,你自己试一下就知道了!! --I didn't test the code, but it should be enough to let you get the idea how to use Calendar to skip "Sunday". I didn't get your salary, you should do the job to incorporate the code.
Calendar end = Calendar.getInstance();
start.set(2001, 0, 1, 0, 0, 0);
end.set(2001, 0, 31, 0, 0, 0);
int size = end.get(Calendar.DATE) - start.get(Calendar.DATE);
boolean[] flag=new boolean[size];
Calendar temp = Calendar.getInstance();
//get your resultset
while (rs.next()) {
Date work = rs.getDate("date");
temp.setTime(date);
if (temp.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
continue;
int offset = temp.get(Calendar.DATE) - start.get(Calendar.DATE);
if (offset > size)
continue;
else
flag[offset]=true;
}
for (int i=0; i<flag.length; i++)
{
if (!flag[i]) {
start.add(Calendar.DATE, i);
System.out.println(start.getTime());
start.add(Calendar.DATE, -i);
}
}
麻烦解决一下,帮帮忙!!!
麻烦解决一下,帮帮忙!!!
--
Calendar cal1 = Calendar.getInstance();
cal1.set(2001, 10, 1, 0, 0, 0);
Calendar cal2 = Calendar.getInstance();
cal2.set(2001, 10, 28, 0, 0, 0);
System.out.println(cal2.get(Calendar.DATE)-cal1.get(Calendar.DATE));
--output is 27
而并没有进行比较!!!
--我后面的代码是干什么的?
while (rs.next()) {
Date work = rs.getDate("date");
temp.setTime(date);
if (temp.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
continue;
int offset = temp.get(Calendar.DATE) - start.get(Calendar.DATE);
if (offset > size)
continue;
else
flag[offset]=true;
}
for (int i=0; i<flag.length; i++)
{
if (!flag[i]) {
start.add(Calendar.DATE, i);
System.out.println(start.getTime());
start.add(Calendar.DATE, -i);
}
}
--Like what?
你自己有没有试过,你自己试一下就知道了!!
--I didn't test the code, but it should be enough to let you get the idea how to use Calendar to skip "Sunday". I didn't get your salary, you should do the job to incorporate the code.
帮帮忙?我实在是没有办法了,多谢!!!!!