android获取今天周几的示例
发布日期:2021-11-22 04:29:01 浏览次数:2 分类:技术文章

本文共 890 字,大约阅读时间需要 2 分钟。

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

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;    }

转载地址:https://blog.csdn.net/zxwd2015/article/details/51272924 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:HTML的实体符号
下一篇:Python 正则表达式的简单使用示例

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月06日 07时32分43秒