jode-time 获得一个的日历
public class JodaTimeTest {
public static void main(String[] args){
List<DateTime> list = getDateTimesByMonth(DateTime.now());
for(DateTime t :list){
System.out.println("dyaofWeek:"+t.getDayOfWeek());
System.out.println("getBirthMonthText:"+t.toString());
}
}
public static List<DateTime> getDateTimesByMonth(DateTime d){
DateTime temp = new DateTime(d.getYear(),d.getMonthOfYear(),1,0,0);
List<DateTime> list = new ArrayList<DateTime>();
//上月(根据需求进行改变)
int week = temp.getDayOfWeek();
if(week!=7){
for(int i=0;i<week;i++){
list.add(temp.plusDays(-week+i));
}
}
//本月
list.add(temp);
for(int i=1;i<=31;i++){
temp = temp.plusDays(1);
if(temp.getMonthOfYear() != d.getMonthOfYear())break;
list.add(temp);
}
//下月(根据需求进行改变)
if(temp.getDayOfWeek() !=6){
for(int i=0;i<7;i++){
temp = temp.plusDays(1);
if(temp.getDayOfWeek() == 7)break;
list.add(temp);
}
}
return list;
}
}
?