zoukankan      html  css  js  c++  java
  • 打印某一个月的日历

    Calendar calendar=Calendar.getInstance();
            calendar.set(2016,11,1);//实际Calendar对象所表示的时间为2.16.12月
            char[] title={'','','','','','',''};
            int daysArray[][]=new int[6][7];
            int daysInMonth=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            int index=calendar.get(Calendar.DAY_OF_WEEK)-1;
            int days=1;
            for(int i=index;i<7;i++){
                daysArray[0][i]=days++;
            }
            for(int i=1;i<6;i++){
                for(int j=0;j<7;j++){
                    if(days>daysInMonth){
                        i=6;
                        break;
                    }else{
                    daysArray[i][j]=days++;
                    }
                }
            }
            System.out.println("---------------------2016年12月-----------------------");
            for(int i=0;i<title.length;i++){
                System.out.print(title[i]+"	");
            }
            System.out.println("
    ");
            for(int i=0;i<6;i++){
                for(int j=0;j<7;j++){
                    if(daysArray[i][j]==0){
                        if(i!=0){
                            return;
                        }
                        System.out.print("	");
                        continue;
                    }
                    System.out.print(daysArray[i][j]+"	");
                }
                System.out.println("
    ");
            }
            
            
        }
    ---------------------2016年12月-----------------------
    日    一    二    三    四    五     六    

                     1    2     3    

    4     5     6    7    8    9     10    

    11    12    13    14    15    16    17    

    18    19    20    21    22    23    24    

    25    26    27    28    29    30    31   
  • 相关阅读:
    VGA Vesa DDC显示接口
    sourceinsight 技巧
    framebuffer 相关
    Windows Live Writer 粘贴表格的使用技巧
    The Linux Kernel API
    XBAP and Silverlight : Product Lining in .NET 3.0/WPF
    DDC and EDID
    cmem模块,cmemk
    Linux Platform Device and Driver,platform_add_devices()>platform_driver_register()
    platform设备驱动全透析
  • 原文地址:https://www.cnblogs.com/tjlgdx/p/6148757.html
Copyright © 2011-2022 走看看