public class Quarter extends RegularTimePeriod implements java.io.Serializable
RegularTimePeriod subclasses.| Modifier and Type | Field and Description |
|---|---|
static int[] |
FIRST_MONTH_IN_QUARTER
The first month in each quarter.
|
static int |
FIRST_QUARTER
Constant for quarter 1.
|
static int[] |
LAST_MONTH_IN_QUARTER
The last month in each quarter.
|
static int |
LAST_QUARTER
Constant for quarter 4.
|
DEFAULT_TIME_ZONE, WORKING_CALENDAR| Constructor and Description |
|---|
Quarter()
Constructs a new Quarter, based on the current system date/time.
|
Quarter(java.util.Date time)
Constructs a new instance, based on a date/time and the default time
zone.
|
Quarter(java.util.Date time,
java.util.TimeZone zone)
Deprecated.
Since 1.0.12, use
Quarter(Date, TimeZone, Locale)
instead. |
Quarter(java.util.Date time,
java.util.TimeZone zone,
java.util.Locale locale)
Creates a new
Quarter instance, using the specified
zone and locale. |
Quarter(int quarter,
int year)
Constructs a new quarter.
|
Quarter(int quarter,
Year year)
Constructs a new quarter.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(java.lang.Object o1)
Returns an integer indicating the order of this Quarter object relative
to the specified object:
negative == before, zero == same, positive == after.
|
boolean |
equals(java.lang.Object obj)
Tests the equality of this Quarter object to an arbitrary object.
|
long |
getFirstMillisecond()
Returns the first millisecond of the quarter.
|
long |
getFirstMillisecond(java.util.Calendar calendar)
Returns the first millisecond in the Quarter, evaluated using the
supplied calendar (which determines the time zone).
|
long |
getLastMillisecond()
Returns the last millisecond of the quarter.
|
long |
getLastMillisecond(java.util.Calendar calendar)
Returns the last millisecond of the Quarter, evaluated using the
supplied calendar (which determines the time zone).
|
int |
getQuarter()
Returns the quarter.
|
long |
getSerialIndex()
Returns a serial index number for the quarter.
|
Year |
getYear()
Returns the year.
|
int |
getYearValue()
Returns the year.
|
int |
hashCode()
Returns a hash code for this object instance.
|
RegularTimePeriod |
next()
Returns the quarter following this one.
|
static Quarter |
parseQuarter(java.lang.String s)
Parses the string argument as a quarter.
|
void |
peg(java.util.Calendar calendar)
Recalculates the start date/time and end date/time for this time period
relative to the supplied calendar (which incorporates a time zone).
|
RegularTimePeriod |
previous()
Returns the quarter preceding this one.
|
java.lang.String |
toString()
Returns a string representing the quarter (e.g.
|
createInstance, downsize, getEnd, getFirstMillisecond, getLastMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMillisecond, getStartpublic static final int FIRST_QUARTER
public static final int LAST_QUARTER
public static final int[] FIRST_MONTH_IN_QUARTER
public static final int[] LAST_MONTH_IN_QUARTER
public Quarter()
public Quarter(int quarter,
int year)
year - the year (1900 to 9999).quarter - the quarter (1 to 4).public Quarter(int quarter,
Year year)
quarter - the quarter (1 to 4).year - the year (1900 to 9999).public Quarter(java.util.Date time)
time - the date/time (null not permitted).Quarter(Date, TimeZone)public Quarter(java.util.Date time,
java.util.TimeZone zone)
Quarter(Date, TimeZone, Locale)
instead.time - the date/time.zone - the zone (null not permitted).public Quarter(java.util.Date time,
java.util.TimeZone zone,
java.util.Locale locale)
Quarter instance, using the specified
zone and locale.time - the current time.zone - the time zone.locale - the locale.public int getQuarter()
public Year getYear()
public int getYearValue()
public long getFirstMillisecond()
peg(Calendar) method.getFirstMillisecond in class RegularTimePeriodgetLastMillisecond()public long getLastMillisecond()
peg(Calendar) method.getLastMillisecond in class RegularTimePeriodgetFirstMillisecond()public void peg(java.util.Calendar calendar)
peg in class RegularTimePeriodcalendar - the calendar (null not permitted).public RegularTimePeriod previous()
previous in class RegularTimePeriodnull if this is
Q1 1900).public RegularTimePeriod next()
next in class RegularTimePeriodpublic long getSerialIndex()
getSerialIndex in class RegularTimePeriodpublic boolean equals(java.lang.Object obj)
true if the target is a Quarter instance
representing the same quarter as this object. In all other cases,
returns false.equals in class java.lang.Objectobj - the object (null permitted).true if quarter and year of this and the object are
the same.public int hashCode()
http://developer.java.sun.com/developer/Books/effectivejava
/Chapter3.pdf
hashCode in class java.lang.Objectpublic int compareTo(java.lang.Object o1)
compareTo in interface java.lang.Comparableo1 - the object to comparepublic java.lang.String toString()
toString in class RegularTimePeriodpublic long getFirstMillisecond(java.util.Calendar calendar)
getFirstMillisecond in class RegularTimePeriodcalendar - the calendar (null not permitted).java.lang.NullPointerException - if calendar is
null.RegularTimePeriod.getLastMillisecond(Calendar)public long getLastMillisecond(java.util.Calendar calendar)
getLastMillisecond in class RegularTimePeriodcalendar - the calendar (null not permitted).java.lang.NullPointerException - if calendar is
null.RegularTimePeriod.getFirstMillisecond(Calendar)public static Quarter parseQuarter(java.lang.String s)
This method should accept the following formats: "YYYY-QN" and "QN-YYYY", where the "-" can be a space, a forward-slash (/), comma or a dash (-).
s - A string representing the quarter.