`
沉睡的鱼
  • 浏览: 69291 次
  • 性别: Icon_minigender_2
  • 来自: 石家庄
社区版块
存档分类
最新评论

判断某一日期是星期几

 
阅读更多
public static String getWeekOfDate(Date dt)
    {
        String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);

        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;

        return weekDays[w];
    }


  public static String getStringDayOfWeek(Date date) {  
                String result = "";  
                if (null != date) {  
                   SimpleDateFormat formatter4 = new SimpleDateFormat("E");  
                   result = formatter4.format(date);  
               }  
               return result;  
            }  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics