日期:2014-05-20  浏览次数:20751 次

怎么通过系统时间得知是星期几?
比如我现在知道日期是个String型的“20071017”。在JAVA里我怎么知道是星期几?

------解决方案--------------------
Date d = new Date(2007,10,7);
System.out.println(d.getDay());
------解决方案--------------------
Java code
public class Test {

    public static void main(String[] args) throws ParseException {
        String str = "20071017";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Date date = sdf.parse(str);
        sdf = new SimpleDateFormat("E");
        System.out.println(str + " " + sdf.format(date));
    }    
}