当前位置: 技术问答>java相关
计算星期一?
来源: 互联网 发布时间:2015-01-29
本文导语: 请问如何根据一个所给的日期计算出该日期所属星期的星期一? 感谢 | String sdate="2001-08-30"; int syear = Integer.parseInt(sdate.substring(0, 4)); int smonth = Integer.parseInt(sdate.substring(5, 7)) - 1; int sday...
请问如何根据一个所给的日期计算出该日期所属星期的星期一?
感谢
感谢
|
String sdate="2001-08-30";
int syear = Integer.parseInt(sdate.substring(0, 4));
int smonth = Integer.parseInt(sdate.substring(5, 7)) - 1;
int sday = Integer.parseInt(sdate.substring(8, 10));
GregorianCalendar cal = new GregorianCalendar();
cal.set(syear, smonth, sday);
week = cal.get(java.util.Calendar.DAY_OF_WEEK);//1为星期天
下面知道怎么做了吧...........
int syear = Integer.parseInt(sdate.substring(0, 4));
int smonth = Integer.parseInt(sdate.substring(5, 7)) - 1;
int sday = Integer.parseInt(sdate.substring(8, 10));
GregorianCalendar cal = new GregorianCalendar();
cal.set(syear, smonth, sday);
week = cal.get(java.util.Calendar.DAY_OF_WEEK);//1为星期天
下面知道怎么做了吧...........