获取指定年,季度的最初时刻

@param year    年份
@param quarter 季度
@return 指定年, 季度的最初时刻日期对象
324019
public static Date dateReservedQuarter000(int year, int quarter) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        if (quarter <= 1) {
            calendar.set(Calendar.MONTH, Calendar.JANUARY);
        } else if (quarter == 2) {
            calendar.set(Calendar.MONTH, Calendar.APRIL);
        } else if (quarter == 3) {
            calendar.set(Calendar.MONTH, Calendar.JULY);
        } else {
            calendar.set(Calendar.MONTH, Calendar.OCTOBER);
        }
        return dateReservedMonth000(calendar);
    }
1254199
public static Date getYear(String string) {
		if (string == null) {
			return null;
		}
		Date date = null;
		try {
			date = ((SimpleDateFormat)year.clone()) .parse(string);
		}
		catch (ParseException ex) {
			return null;
		}
		return date;
	}
606575
function(year) {
			var date = this._validate(year, this.minMonth, this.minDay, $.calendars.local.invalidYear);
			year = date.year();
			return this.toJD((year === -1 ? +1 : year + 1), 7, 1) - this.toJD(year, 7, 1);
		}
161544
public static LinkedHashSet<String> yearAndQuarter(long startDate, long endDate) {
		LinkedHashSet<String> quarters = new LinkedHashSet<>();
		final Calendar cal = calendar(startDate);
		while (startDate <= endDate) {
			// 如果开始时间超出结束时间，让结束时间为开始时间，处理完后结束循环
			quarters.add(yearAndQuarter(cal));

			cal.add(Calendar.MONTH, 3);
			startDate = cal.getTimeInMillis();
		}

		return quarters;
	}
996855
public static Years<CalendarUnit> between(CalendarYear y1, CalendarYear y2) {

        return Years.ofGregorian(y2.getValue() - y1.getValue());

    }
874200
def quarter_to_daterange(quarter):
    """"""
    assert len(quarter) == 6
    year = int(quarter[0:4])
    quarter = quarter[5]
    MONTH_DAY = {
        '1': ((1, 1), (3, 31)),
        '2': ((4, 1), (6, 30)),
        '3': ((7, 1), (9, 30)),
        '4': ((10, 1), (12, 31))
    }
    md = MONTH_DAY[quarter]
    start_md, end_md = md
    return (
        date(year, *start_md),
        date(year, *end_md)
    )
154499
public static boolean isYearTime(String snum)
    {
        if (snum != null)
        {
            int len = snum.length();
            String first = snum.substring(0, 1);

            // 1992年, 98年,06年
            if (isAllSingleByte(snum)
                    && (len == 4 || len == 2 && (cint(first) > 4 || cint(first) == 0)))
                return true;
            if (isAllNum(snum) && (len >= 3 || len == 2 && "０５６７８９".indexOf(first) != -1))
                return true;
            if (getCharCount("零○一二三四五六七八九壹贰叁肆伍陆柒捌玖", snum) == len && len >= 2)
                return true;
            if (len == 4 && getCharCount("千仟零○", snum) == 2)// 二仟零二年
                return true;
            if (len == 1 && getCharCount("千仟", snum) == 1)
                return true;
            if (len == 2 && getCharCount("甲乙丙丁戊己庚辛壬癸", snum) == 1
                    && getCharCount("子丑寅卯辰巳午未申酉戌亥", snum.substring(1)) == 1)
                return true;
        }
        return false;
    }
1276786
public static PeriodType yearMonthDayTime() {
        PeriodType type = cYMDTime;
        if (type == null) {
            type = new PeriodType(
                "YearMonthDayTime",
                new DurationFieldType[] {
                    DurationFieldType.years(), DurationFieldType.months(),
                    DurationFieldType.days(),
                    DurationFieldType.hours(), DurationFieldType.minutes(),
                    DurationFieldType.seconds(), DurationFieldType.millis(),
                },
                new int[] { 0, 1, -1, 2, 3, 4, 5, 6, }
            );
            cYMDTime = type;
        }
        return type;
    }
1242162
def end_of_quarter(year, quarter)
      case quarter
      when QUARTER_1
        end_of_month(year, 3)
      when QUARTER_2
        end_of_month(year, 6)
      when QUARTER_3
        end_of_month(year, 9)
      when QUARTER_4
        end_of_month(year, 12)
      else
        raise "invalid quarter"
      end
    end
1176971
public static int getYearFromData(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return cal.get(Calendar.YEAR);
	}
628328
public static Quarters parsePeriod(String period) throws ParseException {

        int amount = SingleUnitTimeSpan.parsePeriod(period, 'Q');
        return Quarters.of(amount);

    }
227637
def this_quarter():
        
        since = TODAY + delta(day=1)
        while since.month % 3 != 0:
            since -= delta(months=1)
        until = since + delta(months=3)
        return Date(since), Date(until)
1218578
def last_quarter():
        
        since, until = Date.this_quarter()
        since = since.date - delta(months=3)
        until = until.date - delta(months=3)
        return Date(since), Date(until)
526910
public CalendarYear plus(Years<CalendarUnit> years) {

        if (years.isEmpty()) {
            return this;
        }

        return CalendarYear.of(MathUtils.safeAdd(this.year, years.getAmount()));

    }
410385
private void checkJodaGetYear() {
        int COUNT = COUNT_VERY_FAST;
        DateTime dt = new DateTime(GJChronology.getInstance());
        for (int i = 0; i < AVERAGE; i++) {
            start("Joda", "getYear");
            for (int j = 0; j < COUNT; j++) {
                int val = dt.getYear();
                if (val == 0) {System.out.println("Anti optimise");}
            }
            end(COUNT);
        }
    }
542
public CyclicYear roll(int amount) {

        if (amount == 0) {
            return this;
        }

        return CyclicYear.of(MathUtils.floorModulo(MathUtils.safeAdd(this.year - 1, amount), 60) + 1);

    }
542233
private static int getMonthOfYear(int dayOfYear, int year) {

        Integer[] newMonths = getAdjustedMonthDays(year);

        if (dayOfYear >= 0) {
            for (int i = 0; i < newMonths.length; i++) {
                if (dayOfYear < newMonths[i].intValue()) {
                    return i - 1;
                }
            }
            return 11;
        } else {
            dayOfYear = (isLeapYear(year) ? (dayOfYear + 355)
                    : (dayOfYear + 354));
            for (int i = 0; i < newMonths.length; i++) {
                if (dayOfYear < newMonths[i].intValue()) {
                    return i - 1;
                }
            }
            return 11;
        }
    }