public class Quarter extends RegularTimePeriod implements 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(Date time)
Constructs a new instance, based on a date/time and the default time
zone.
|
Quarter(Date time,
TimeZone zone)
Deprecated.
Since 1.0.12, use
Quarter(Date, TimeZone, Locale)
instead. |
Quarter(Date time,
TimeZone zone,
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(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(Object obj)
Tests the equality of this Quarter object to an arbitrary object.
|
long |
getFirstMillisecond()
Returns the first millisecond of the quarter.
|
long |
getFirstMillisecond(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(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(String s)
Parses the string argument as a quarter.
|
void |
peg(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.
|
String |
toString()
Returns a string representing the quarter (e.g.
|
createInstance, downsize, getEnd, getFirstMillisecond, getLastMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMillisecond, getStart
public 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(Date time)
time
- the date/time (null
not permitted).Quarter(Date, TimeZone)
public Quarter(Date time, TimeZone zone)
Quarter(Date, TimeZone, Locale)
instead.time
- the date/time.zone
- the zone (null
not permitted).public int getQuarter()
public Year getYear()
public int getYearValue()
public long getFirstMillisecond()
peg(Calendar)
method.getFirstMillisecond
in class RegularTimePeriod
getLastMillisecond()
public long getLastMillisecond()
peg(Calendar)
method.getLastMillisecond
in class RegularTimePeriod
getFirstMillisecond()
public void peg(Calendar calendar)
peg
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).public RegularTimePeriod previous()
previous
in class RegularTimePeriod
null
if this is
Q1 1900).public RegularTimePeriod next()
next
in class RegularTimePeriod
public long getSerialIndex()
getSerialIndex
in class RegularTimePeriod
public boolean equals(Object obj)
true
if the target is a Quarter instance
representing the same quarter as this object. In all other cases,
returns false
.public int hashCode()
http://developer.java.sun.com/developer/Books/effectivejava
/Chapter3.pdf
public int compareTo(Object o1)
compareTo
in interface Comparable
o1
- the object to comparepublic String toString()
toString
in class RegularTimePeriod
public long getFirstMillisecond(Calendar calendar)
getFirstMillisecond
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).NullPointerException
- if calendar
is
null
.RegularTimePeriod.getLastMillisecond(Calendar)
public long getLastMillisecond(Calendar calendar)
getLastMillisecond
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).NullPointerException
- if calendar
is
null
.RegularTimePeriod.getFirstMillisecond(Calendar)
public static Quarter parseQuarter(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.Jas4pp 1.5 © Java Analysis Studio for Particle Physics