Пример #1
0
 /**
  * Creates a new <code>Quarter</code> instance, using the specified
  * zone and locale.
  *
  * @param time  the current time.
  * @param zone  the time zone.
  * @param locale  the locale.
  *
  * @since 1.0.12
  */
 public Quarter(Date time, TimeZone zone, Locale locale) {
     Calendar calendar = Calendar.getInstance(zone, locale);
     calendar.setTime(time);
     int month = calendar.get(Calendar.MONTH) + 1;
     this.quarter = (byte) SerialDate.monthCodeToQuarter(month);
     this.year = (short) calendar.get(Calendar.YEAR);
     peg(calendar);
 }
Пример #2
0
 /**
  * Constructs a new quarter.
  *
  * @param quarter  the quarter (1 to 4).
  * @param year  the year (1900 to 9999).
  */
 public Quarter(int quarter, Year year) {
     if ((quarter < FIRST_QUARTER) || (quarter > LAST_QUARTER)) {
         throw new IllegalArgumentException("Quarter outside valid range.");
     }
     this.year = (short) year.getYear();
     this.quarter = (byte) quarter;
     peg(Calendar.getInstance());
 }