从数据库把日期取出来了,格式是2006-03-25 ,怎么算这天是星期几啊

解决方案 »

  1.   

    import java.util.Calendar;public class Demo {
    final static String [] NAME =new String[]{"",
      "SUNDAY" ,"MONDAY", "TUESDAY" ,"WEDNESDAY", "THURSDAY" , "FRIDAY" , "SATURDAY"};
    public static void main(String[] args) {
    System.out.println(NAME[getDayOfWeek(2006,3,1)]);

    }
    public static int getDayOfWeek(int year,int month,int day){
    Calendar c = Calendar.getInstance() ;
    c.set(year,month-1,day);
    return c.get(Calendar.DAY_OF_WEEK);
    }}
      

  2.   

    wizardblue(不死鱼) 的方法我在网上搜到的,不实用
      

  3.   

    <%=Date2Week(getShortDate(scp.getTime()))%>getShortDate法是这样
     public static String getShortDate(long lngTime)
        {
            return getShortDate(new Date(lngTime));
        }Date2Week方法如下
     public static String Date2Week(String ymd) {
            try {
                Date date = df.parse(ymd);
                return df_week.format(date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return null;
            }
        }其中public static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 
    public static SimpleDateFormat df_week = new SimpleDateFormat("E");现在ok了