欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java,

来源: javaer 分享于  点击 44012 次 点评:6

java,


package com.test;

import java.util.Calendar;

public class Test {

	/**
	 * @param argsfsdf
	 */
	
	public void testIf(){
		//获取当前时间
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int month = cal.get(Calendar.MONTH )+1;
		int day = cal.get(Calendar.DAY_OF_MONTH);
		System.out.println("今天是"+year + " 年 " + month + " 月"+ day +" 日 ");
	    if(month == 1){
	    	day = 31;
	    }else if(month == 2){
	    	day = 28;
	    } else if(month == 3){
	    	day = 31;
	    } else if(month == 4){
	    	day = 30;
	    } else if(month == 5){
	    	day = 31;
	    } else if(month == 6){
	    	day = 30;
	    } else if(month == 7){
	    	day = 31;
	    } else if(month == 8){
	    	day = 31;
	    } else if(month == 9){
	    	day = 30;
	    } else if(month == 10){
	    	day = 31;
	    } else if(month == 11){
	    	day = 30;
	    } else if(month == 12){
	    	day = 31;
	    }
	    System.out.println(day);
		
	}
	
	public static void main(String args[]){
		Test t = new Test();
		t.testIf();
	}

}






相关文章

    暂无相关文章
相关栏目:

用户点评