JAVA如何得到当前日期是星期几?求JAVA代码

解决方案 »

  1.   


    String week="";
            java.text.DateFormat df = new java.text.SimpleDateFormat("E") ;
        week = df.format(new java.util.Date()) ;
            out.println(week);
      

  2.   

    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);   
    }  本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/a9529lty/archive/2008/11/02/3206942.aspx