标签:get string 博客 date 界面 public
如题,将传入的日期转换为星期几,转换方法:
public String getWeekDay(Calendar calendar) {
String[] weeks =
{"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
int m =
calendar.get(Calendar.DAY_OF_WEEK)-1;
if(m<0){
m=6;
}
return
weeks[m];
}
demo: 转换昨天为星期几
Calendar calendar =
Calendar.getInstance();
calendar.add(Calendar.DATE, -1);
//得到星期几
getWeekDay(calendar);
注:刚开始写博客,还没来得及看怎么排版,界面太丑,望看客轻喷..
标签:get string 博客 date 界面 public
原文地址:http://www.cnblogs.com/JavatechBlog/p/3773118.html