admin管理员组

文章数量:1122908

php显示某年某月某日,Android获取指定某年某月某日相对应星期,某年某月有几天...

JAVA中有封装好的函数来调用的

获取当前系统年月日

Calendar calendar = Calendar.getInstance();

int year = calendar.get(Calendar.YEAR);

int month = calendar.get(Calendar.MONTH) + 1;// Java月份从0开始算

int day = calendar.get(Calendar.DAY_OF_MONTH);

获取指定某年某月某日相关的需求

Calendar calendar = Calendar.getInstance();

calendar.set(Calendar.YEAR, year);//先指定年份

calendar.set(Calendar.MONTH, month - 1);//再指定月份 Java月份从0开始算

int daysCountOfMonth = calendar.getActualMaximum(Calendar.DATE);//获取指定年份中指定月份有几天

//获取指定年份月份中指定某天是星期几

calendar.set(Calendar.DAY_OF_MONTH, day);

int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);

switch (dayOfWeek)

{

case 1:

weekTextView.setText("星期日");

break;

case 2:

weekTextView.setText("星期一");

break;

case 3:

weekTextView.setText("星期二");

break;

case 4:

weekTextView.setText("星期三");

break;

case 5:

weekTextView.setText("星期四");

break;

case 6:

weekTextView.setText("星期五");

break;

case 7:

weekTextView.setText("星期六");

break;

}

本文标签: php显示某年某月某日Android获取指定某年某月某日相对应星期,某年某月有几天