资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java怎么打印指定年月的日历

本篇内容主要讲解“java怎么打印指定年月的日历”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“java怎么打印指定年月的日历”吧!

创新互联-云计算及IDC服务提供商,涵盖公有云、IDC机房租用、服务器托管、等保安全、私有云建设等企业级互联网基础服务,欢迎来电:028-86922220

程序如下:

//打印指定年月的日历public class PrintCalendar {  public static void main(String[] args) { int year=2013; int month=12; printMonth(year,month); }  private static void printMonth(int year, int month) {//打印日历 printMonthTitle(year,month); printMonthBody(year,month); }  private static void printMonthTitle(int year, int month) {//打印日历标题 System.out.println("   "+getMonthName(month)+" "+year); System.out.println("------------------------------"); System.out.println(" Sun Mon Tue Wed Thu Fri Sat"); }  private static String getMonthName(int month) { String monthName=null; switch(month){ case 1:monthName="January";break; case 2:monthName="February";break; case 3:monthName="March";break; case 4:monthName="April";break; case 5:monthName="May";break; case 6:monthName="June";break; case 7:monthName="July";break; case 8:monthName="August";break; case 9:monthName="September";break; case 10:monthName="October";break; case 11:monthName="November";break; case 12:monthName="December"; } return monthName; }  public static boolean isLeapYear(int year){//判断是否为闰年 return year%400==0||(year%4==0&&year%100!=0); }  public static int getNumberOfDaysInMonth(int year,int month){//获取对应月份天数 if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)  return 31; if(month==4||month==6||month==9||month==11)  return 30; if(month==2)  return isLeapYear(year)?29:28; return 0; }  public static int getTotalNumberOfDays(int year,int month){//获取从1800年到当月的总天数 int total=0; for(int i=1800;i

到此,相信大家对“java怎么打印指定年月的日历”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


文章标题:java怎么打印指定年月的日历
浏览地址:http://cdkjz.cn/article/ihcceo.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220