/** * Returns the year. * * @return The year. */ public Year getYear() { return new Year(this.year); }
/** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (<code>null</code> not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); }
result = this.year - y.getYear();
/** * Creates a year from a string, or returns null (format exceptions * suppressed). * * @param s string to parse. * * @return {@code null} if the string is not parseable, the year * otherwise. */ private static Year evaluateAsYear(String s) { Year result = null; try { result = Year.parseYear(s); } catch (TimePeriodFormatException e) { // suppress } return result; }
/** * Creates a time period representing a single year. * * @param year the year. */ public Year(int year) { if ((year < Year.MINIMUM_YEAR) || (year > Year.MAXIMUM_YEAR)) { throw new IllegalArgumentException( "Year constructor: year (" + year + ") outside valid range."); } this.year = (short) year; peg(Calendar.getInstance()); }
/** * Creates a year from a string, or returns {@code null} (format * exceptions suppressed). * * @param s the string to parse. * * @return {@code null} if the string is not parseable, the year * otherwise. */ private static Year evaluateAsYear(String s) { Year result = null; try { result = Year.parseYear(s); } catch (TimePeriodFormatException e) { // suppress } return result; }
/** * Creates a time period representing a single year. * * @param year the year. */ public Year(int year) { if ((year < Year.MINIMUM_YEAR) || (year > Year.MAXIMUM_YEAR)) { throw new IllegalArgumentException( "Year constructor: year (" + year + ") outside valid range."); } this.year = (short) year; peg(Calendar.getInstance()); }
/** * Returns the year. * * @return The year. */ public Year getYear() { return new Year(this.year); }
result = this.year - y.getYear();
/** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar ({@code null} not permitted). * * @since 1.0.3 */ @Override public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); }
/** * Creates a year from a string, or returns null (format exceptions * suppressed). * * @param s string to parse. * * @return <code>null</code> if the string is not parseable, the year * otherwise. */ private static Year evaluateAsYear(String s) { Year result = null; try { result = Year.parseYear(s); } catch (TimePeriodFormatException e) { // suppress } return result; }
/** * Creates a new {@code Year} instance, for the specified time zone * and locale. * * @param time the current time ({@code null} not permitted). * @param zone the time zone. * @param locale the locale. * * @since 1.0.12 */ public Year(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.year = (short) calendar.get(Calendar.YEAR); peg(calendar); }
/** * Returns the year in which the week falls. * * @return The year (never {@code null}). */ public Year getYear() { return new Year(this.year); }
/** * 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()); }
/** * Creates a year from a string, or returns <code>null</code> (format * exceptions suppressed). * * @param s the string to parse. * * @return <code>null</code> if the string is not parseable, the year * otherwise. */ private static Year evaluateAsYear(String s) { Year result = null; try { result = Year.parseYear(s); } catch (TimePeriodFormatException e) { // suppress } return result; }
/** * Creates a new <code>Year</code> instance, for the specified time zone * and locale. * * @param time the current time (<code>null</code> not permitted). * @param zone the time zone. * @param locale the locale. * * @since 1.0.12 */ public Year(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.year = (short) calendar.get(Calendar.YEAR); peg(calendar); }
/** * Returns the year in which the month falls. * * @return The year in which the month falls (as a Year object). */ public Year getYear() { return new Year(this.year); }
/** * Constructs a new month instance. * * @param month the month (in the range 1 to 12). * @param year the year. */ public Month(int month, Year year) { if ((month < 1) || (month > 12)) { throw new IllegalArgumentException("Month outside valid range."); } this.month = month; this.year = year.getYear(); peg(Calendar.getInstance()); }
Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result;
/** * Returns the year in which the week falls. * * @return The year (never <code>null</code>). */ public Year getYear() { return new Year(this.year); }