分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
方法1:
- /**
- * 判断当前日期是星期几<br>
- * <br>
- * @param pTime 修要判断的时间<br>
- * @return dayForWeek 判断结果<br>
- * @Exception 发生异常<br>
- */
- public static int dayForWeek(String pTime) throws Exception {
- format = new SimpleDateFormat("yyyy-MM-dd");
- Calendar c = Calendar.getInstance();
- c.setTime(format.parse(pTime));
- int dayForWeek = 0;
- if(c.get(Calendar.DAY_OF_WEEK) == 1){
- dayForWeek = 7;
- }else{
- dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
- }
- return dayForWeek;
- }
方法2:
需要导入的包
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
- public static int dayForWeek(String pTime) throws Throwable {
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Date tmpDate = format.parse(pTime);
- Calendar cal = new GregorianCalendar();
- cal.set(tmpDate.getYear(), tmpDate.getMonth(), tmpDate.getDay());
- return cal.get(Calendar.DAY_OF_WEEK);
- }
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)