Calendar cal = Calendar.getInstance();//初始化
SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.CHINA); //设置显示格式,地区
Date currentTime = new Date(); String dateString = formatter.format(currentTime); //取得今天时间
int year = cal.get(Calendar.YEAR);//取得年
int mouth = cal.get(Calendar.MONTH) + 1;//取得月
int week = cal.get(Calendar.WEEK_OF_MONTH); //取得周
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK)//取得每周的第几天
int dayOfMouth = cal.get(Calendar.DAY_OF_MOUTH)//取得每周的第几天
本文介绍如何使用Java中的Calendar和SimpleDateFormat类来获取当前日期时间、年份、月份、周数及周内天数等信息。
2767

被折叠的 条评论
为什么被折叠?



