final Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); mYear = String.valueOf(calendar.get(Calendar.YEAR)); // 获取当前年份 mMonth = String.valueOf(calendar.get(Calendar.MONTH) + 1); // 获取当前月份 mDay = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); // 获取当前月份的日期号码 mWay = String.valueOf(calendar.get(Calendar.DAY_OF_WEEK)); //获取当前周几 mHour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)); //获取当前小时 mMinute = String.valueOf(calendar.get(Calendar.MINUTE)); //获取当前多少分
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 ="六"; } tvTime.setText(mHour + ":" + mMinute); tvDate.setText(mMonth + "月"+ mDay + "日" + " 星期" + mWay);