android获取今天周几的示例

来源:互联网 发布:网络维护常用工具 编辑:程序博客网 时间:2024/05/22 01:43

项目中需要展示 星期几,没做过果断 百度一下,参考别人代码修改一下,整理存放以供学习扩展

 public static String getWeekDay(int off) {        String result = new String("");        final Calendar instance = Calendar.getInstance();        instance.setTimeInMillis(System.currentTimeMillis());        int day = instance.get(Calendar.DAY_OF_WEEK);        int offDay = day + off;        switch (offDay % 7) {            case 0:                result = "周六";                break;            case 1:                result = "周日";                break;            case 2:                result = "周一";                break;            case 3:                result = "周二";                break;            case 4:                result = "周三";                break;            case 5:                result = "周四";                break;            case 6:                result = "周五";                break;        }        return result;    }


1 0
原创粉丝点击