码迷,mamicode.com
首页 > 移动开发 > 详细

Android获取当前时间与星期几

时间:2016-06-15 09:09:06      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

public class DataString {
    private static String mYear;
    private static String mMonth;
    private static String mDay;
    private static String mWay;
    
    public static String StringData(){
        final Calendar c = Calendar.getInstance();
        c.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
        mYear = String.valueOf(c.get(Calendar.YEAR)); // 获取当前年份
        mMonth = String.valueOf(c.get(Calendar.MONTH) + 1);// 获取当前月份
        mDay = String.valueOf(c.get(Calendar.DAY_OF_MONTH));// 获取当前月份的日期号码
        mWay = String.valueOf(c.get(Calendar.DAY_OF_WEEK));
        if("1".equals(mWay)){
            mWay ="";
        }else if("2".equals(mWay)){
            mWay ="";
        }else if("3".equals(mWay)){
            mWay ="";
        }else if("4".equals(mWay)){
            mWay ="";
        }else if("5".equals(mWay)){
            mWay ="";
        }else if("6".equals(mWay)){
            mWay ="";
        }else if("7".equals(mWay)){
            mWay ="";
        }
        return mYear + "" + mMonth + "" + mDay+""+"/星期"+mWay;
    }
    
}

 

Android获取当前时间与星期几

标签:

原文地址:http://www.cnblogs.com/zhujiabin/p/5586171.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!