日期:2014-05-17  浏览次数:20771 次

求一个当前日期是星期几的算法
求一个当前日期是星期几的算法,要求使用java内置的日期库实现

------解决方案--------------------
我给你提供一个参考,直接使用的java内置的日期库实现 
Java获得当前日期是星期几的代码
http://www.iii-soft.com/forum.php?mod=viewthread&tid=1965
---------------------------------------------------------------
记得给分啊
------解决方案--------------------
Calendar.getInstance().get(Calendar.DAY_OF_WEEK)

------解决方案--------------------

String weeks[] = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
Calendar weekStart = Calendar.getInstance();
weekStart.setTime(new Date());
int index = weekStart.get(Calendar.DAY_OF_WEEK);
System.out.println(weeks[index-1]);

------解决方案--------------------

    /**
     * Field number for <code>get</code> and <code>set</code> indicating the day
     * of the week.  This field takes values <code>SUNDAY</code>,
     * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>,
     * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>.
     *
     * @see #SUNDAY
     * @see #MONDAY
     * @see #TUESDAY
     * @see #WEDNESDAY
     * @see #THURSDAY
     * @see #FRIDAY
     * @see #SATURDAY
     */
    public final static int DAY_OF_WEEK = 7;

------解决方案--------------------
还在用java内置time api呢, 给你推荐个jodatime时间框架,100% java匹配, DateTime time = new DateTime();

time.getDayOfWeek() 一句代码的事情,获取当前星期,也可以指定日期,构造是传入就行