public static void main(String[] args) {
DateTime day = new DateTime(2013, 1, 1, 0, 0);
while(day.getYear() == 2013) {
System.out.print(day + " ");
System.out.print(getQuarterInMonth(day, true) + " ");;
System.out.println(getQuarterInMonth(day, false));;
day = day.plusDays(1);
}
}
private static DateTime getQuarterInMonth(DateTime time, boolean isQuarterStart) {
int month = time.getMonthOfYear();//获取当前时间的月份
month = (month / 3 + (month % 3 == 0 ? 0 : 1)) * 3 - 2;//当前月份是第几季度
int year = time.getYear();//当前时间的年份
if(!isQuarterStart) {
month += 3;
}
if(month == 13) {
year += 1;
month = 1;
}
return new DateTime(year, month, 1, 0, 0);
}