从2007年5月31日开始 循环显示每个月的31日,循环10次,高手们有没有好办法这里有两个问题,一是  跨年  二是  每月的天数不同,还有润月

解决方案 »

  1.   

    不大明白你的意思
    如果只是列出有31天的月数,按
    CrazyGou(阿狗)(...) ( )
    就差不多了
      

  2.   

    每月最后1天java好像有现成的sql也可以写出来select last_day(add_months(to_date('2007/02/02','yyyy/mm/dd'),i)) from dual
    //2007/02/02后的第i个月的最后1天你再传值i进去,循环就可以了
      

  3.   

    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
    February = 29days;
    else
    February = 28days;
      

  4.   


    import java.text.SimpleDateFormat;
    import java.util.Date;/*
     * Created on 2007-5-12
     *//**
     * @author luohan 
     * 从今天开始 循环显示每个月的31日,循环10次
     */
    public class Theday31 {    public static void main(String[] args) {
            String[] theday = new String[10];
            SimpleDateFormat sdf = new SimpleDateFormat("dd");
            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
            int num = 0;
            Date date = new Date();
            long lon = (date.getTime() / 1000);        for (;;) {
                lon = (date.getTime() / 1000) + 60 * 60 * 24;
                date.setTime(lon * 1000);
                String day = sdf.format(date);
                if (Integer.parseInt(day) == 31) {
                    System.out.println(sdf1.format(date) + "");
                    num += 1;
                    if (num == 10) {
                        break;
                    }
                }
            }    }
    }
      

  5.   

    Calendar c = Calendar.getInstance();
            c.clear();
            c.setTime(new SimpleDateFormat("yyyy年MM月dd日").parse("2006年5月31日"));
            int year = 0;
            int month = 0;
            int day = 0;
            for(int i = 0; i < 10; i++){
                year = c.get(Calendar.YEAR);
                month = c.get(Calendar.MONTH) + 1;
                day = c.getActualMaximum(Calendar.DATE);
                System.out.println(year + "年" + month + "月" + day + "日");
                c.add(Calendar.MONTH, 1);            
            }