@Test public void testParseQuarter() { Quarter quarter = Quarter.parseQuarter("Q1-2000"); assertEquals(1, quarter.getQuarter()); assertEquals(2000, quarter.getYear().getYear()); quarter = Quarter.parseQuarter("2001-Q2"); assertEquals(2, quarter.getQuarter()); assertEquals(2001, quarter.getYear().getYear()); quarter = Quarter.parseQuarter("Q3, 2002"); assertEquals(3, quarter.getQuarter()); assertEquals(2002, quarter.getYear().getYear()); }
public static Quarter parseQuarter(String s) { int i = s.indexOf("Q"); if (i == -1) { throw new TimePeriodFormatException("Missing Q."); } if (i == s.length() - 1) { throw new TimePeriodFormatException("Q found at end of string."); } String qstr = s.substring(i + 1, i + 2); int quarter = Integer.parseInt(qstr); String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); remaining = remaining.replace('/', ' '); remaining = remaining.replace(',', ' '); remaining = remaining.replace('-', ' '); Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result; }
Quarter extends RegularTimePeriod implements Serializable { public static Quarter parseQuarter(String s) { int i = s.indexOf("Q"); if (i == -1) { throw new TimePeriodFormatException("Missing Q."); } if (i == s.length() - 1) { throw new TimePeriodFormatException("Q found at end of string."); } String qstr = s.substring(i + 1, i + 2); int quarter = Integer.parseInt(qstr); String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); remaining = remaining.replace('/', ' '); remaining = remaining.replace(',', ' '); remaining = remaining.replace('-', ' '); Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result; } }
Quarter extends RegularTimePeriod implements Serializable { public static Quarter parseQuarter(String s) { int i = s.indexOf("Q"); if (i == -1) { throw new TimePeriodFormatException("Missing Q."); } if (i == s.length() - 1) { throw new TimePeriodFormatException("Q found at end of string."); } String qstr = s.substring(i + 1, i + 2); int quarter = Integer.parseInt(qstr); String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); remaining = remaining.replace('/', ' '); remaining = remaining.replace(',', ' '); remaining = remaining.replace('-', ' '); Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result; } Quarter();  Quarter(int quarter, int year);  Quarter(int quarter, Year year);  Quarter(Date time);  Quarter(Date time, TimeZone zone, Locale locale); }
Quarter extends RegularTimePeriod implements Serializable { public static Quarter parseQuarter(String s) { int i = s.indexOf("Q"); if (i == -1) { throw new TimePeriodFormatException("Missing Q."); } if (i == s.length() - 1) { throw new TimePeriodFormatException("Q found at end of string."); } String qstr = s.substring(i + 1, i + 2); int quarter = Integer.parseInt(qstr); String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); remaining = remaining.replace('/', ' '); remaining = remaining.replace(',', ' '); remaining = remaining.replace('-', ' '); Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result; } Quarter();  Quarter(int quarter, int year);  Quarter(int quarter, Year year);  Quarter(Date time);  Quarter(Date time, TimeZone zone, Locale locale); int getQuarter(); Year getYear(); int getYearValue(); @Override long getFirstMillisecond(); @Override long getLastMillisecond(); @Override void peg(Calendar calendar); @Override RegularTimePeriod previous(); @Override RegularTimePeriod next(); @Override long getSerialIndex(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(TimePeriod o1); @Override String toString(); @Override long getFirstMillisecond(Calendar calendar); @Override long getLastMillisecond(Calendar calendar); static Quarter parseQuarter(String s); }
Quarter extends RegularTimePeriod implements Serializable { public static Quarter parseQuarter(String s) { int i = s.indexOf("Q"); if (i == -1) { throw new TimePeriodFormatException("Missing Q."); } if (i == s.length() - 1) { throw new TimePeriodFormatException("Q found at end of string."); } String qstr = s.substring(i + 1, i + 2); int quarter = Integer.parseInt(qstr); String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); remaining = remaining.replace('/', ' '); remaining = remaining.replace(',', ' '); remaining = remaining.replace('-', ' '); Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result; } Quarter();  Quarter(int quarter, int year);  Quarter(int quarter, Year year);  Quarter(Date time);  Quarter(Date time, TimeZone zone, Locale locale); int getQuarter(); Year getYear(); int getYearValue(); @Override long getFirstMillisecond(); @Override long getLastMillisecond(); @Override void peg(Calendar calendar); @Override RegularTimePeriod previous(); @Override RegularTimePeriod next(); @Override long getSerialIndex(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(TimePeriod o1); @Override String toString(); @Override long getFirstMillisecond(Calendar calendar); @Override long getLastMillisecond(Calendar calendar); static Quarter parseQuarter(String s); static final int FIRST_QUARTER; static final int LAST_QUARTER; static final int[] FIRST_MONTH_IN_QUARTER; static final int[] LAST_MONTH_IN_QUARTER; }