网站建设资讯

NEWS

网站建设资讯

获取某月天数的方法

JavaScript:

创新互联建站主要从事成都网站设计、做网站、成都外贸网站建设公司、网页设计、企业做网站、公司建网站等业务。立足成都服务玉山,十多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792

function getLeap(iYear,iMonth)
{
var DayNumber=new Array(11) //Array to save every month days
DayNumber[0]=DayNumber[2]=DayNumber[4]=DayNumber[6]=DayNumber[7]=DayNumber[9]=DayNumber[11]=31;
DayNumber[3]=DayNumber[5]=DayNumber[8]=DayNumber[10]=30;
if (iYear%4==0&&((iYear%100!=0)||(iYear%400==0)))
DayNumber[1] = 29;
else
DayNumber[1] = 28;

return DayNumber[iMonth-1];
}

SQL:

SELECT to_number( to_char(last_day(to_date('2007-01-24','yyyy-mm-dd')),'DD')) from dual

java:

public static int getMaxDaysOfMonth(String parsemonth) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");

Calendar calendar = new GregorianCalendar();
if (parsemonth!=null&&parsemonth.length()>7)
{
parsemonth =parsemonth.substring(0,7);
}
Date date = new Date();
try {
date = sdf.parse(parsemonth);
} catch (ParseException e) {
e.printStackTrace();
}
calendar.setTime(date);
int day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
return day;
}

[@more@]
本文题目:获取某月天数的方法
URL链接:http://cdweb.net/article/isjepp.html