import java.util.Calendar;
import java.util.Date;
public class test {
public static String getWeekOfMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
//外国月份为0-11所以月份加一
int month = cal.get(Calendar.MONTH)+1;
int mweek = cal.get(Calendar.WEEK_OF_MONTH);
String d = month+"第"+mweek+"周";
return d;
}
public static void main(String[] args) {
System.out.println(getWeekOfMonth(new Date()));
}
}
将date转化为时间类型,分别获取这个时间的年月,然后根据时间获取第几周最后将两者以字符串的形式链接在一起!!