org.jfree.data.time.Quarter Java Examples

The following examples show how to use org.jfree.data.time.Quarter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L).  Use
 * this to check the quarter constructor.
 */
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul");
    Calendar c = new GregorianCalendar(zone);
    Quarter q1 = new Quarter(new Date(1017608399999L), zone, 
    		Locale.getDefault());
    Quarter q2 = new Quarter(new Date(1017608400000L), zone, 
    		Locale.getDefault());

    assertEquals(1, q1.getQuarter());
    assertEquals(1017608399999L, q1.getLastMillisecond(c));

    assertEquals(2, q2.getQuarter());
    assertEquals(1017608400000L, q2.getFirstMillisecond(c));

}
 
Example #2
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithCalendar() {
    Quarter q = new Quarter(1, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(978307200000L, q.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        q.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #3
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithTimeZone() {
    Quarter q = new Quarter(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-623347200000L, q.getFirstMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        q.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #4
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithTimeZone() {
    Quarter q = new Quarter(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-615488400001L, q.getLastMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        q.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #5
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Quarter q = new Quarter(3, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(1001894399999L, q.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        q.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #6
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithTimeZone() {
    Quarter q = new Quarter(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-623347200000L, q.getFirstMillisecond(c));
    
    // try null calendar
    boolean pass = false;
    try {
        q.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);            
}
 
Example #7
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithCalendar() {
    Quarter q = new Quarter(1, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(978307200000L, q.getFirstMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        q.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #8
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithTimeZone() {
    Quarter q = new Quarter(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-615488400001L, q.getLastMillisecond(c));
    
    // try null calendar
    boolean pass = false;
    try {
        q.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);            
}
 
Example #9
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L).  Use this
 * to check the quarter constructor.
 */
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Quarter q1 = new Quarter(new Date(1017619199999L), zone, 
    		Locale.getDefault());
    Quarter q2 = new Quarter(new Date(1017619200000L), zone, 
    		Locale.getDefault());

    assertEquals(1, q1.getQuarter());
    assertEquals(1017619199999L, q1.getLastMillisecond(c));

    assertEquals(2, q2.getQuarter());
    assertEquals(1017619200000L, q2.getFirstMillisecond(c));

}
 
Example #10
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Quarter q = new Quarter(3, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(1001894399999L, q.getLastMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        q.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #11
Source File: ChartConstants.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Class getTimePeriodClass( final String timePeriodStr ) {
  Class retClass = Millisecond.class;
  if ( timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR ) ) {
    retClass = Second.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR ) ) {
    retClass = Minute.class;
  } else if ( timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR ) ) {
    retClass = Hour.class;
  } else if ( timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR ) ) {
    retClass = Day.class;
  } else if ( timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR ) ) {
    retClass = Week.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR ) ) {
    retClass = Month.class;
  } else if ( timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR ) ) {
    retClass = Quarter.class;
  } else if ( timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR ) ) {
    retClass = Year.class;
  }
  return retClass;
}
 
Example #12
Source File: TimeSeriesCollectorFunction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Class getTimePeriodClass( final String timePeriodStr ) {
  Class retClass = Millisecond.class;
  if ( timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR ) ) {
    retClass = Second.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR ) ) {
    retClass = Minute.class;
  } else if ( timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR ) ) {
    retClass = Hour.class;
  } else if ( timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR ) ) {
    retClass = Day.class;
  } else if ( timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR ) ) {
    retClass = Week.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR ) ) {
    retClass = Month.class;
  } else if ( timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR ) ) {
    retClass = Quarter.class;
  } else if ( timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR ) ) {
    retClass = Year.class;
  }
  return retClass;
}
 
Example #13
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    Quarter q1 = new Quarter(2, 2003);
    Quarter q2 = new Quarter(2, 2003);
    assertTrue(q1.equals(q2));
    int h1 = q1.hashCode();
    int h2 = q2.hashCode();
    assertEquals(h1, h2);
}
 
Example #14
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getEnd() method.
 */
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.MARCH, 31, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);
    Quarter q = new Quarter(1, 2006);
    assertEquals(cal.getTime(), q.getEnd());
    Locale.setDefault(saved);
}
 
Example #15
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L).  Use
 * this to check the quarter constructor.
 */
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul");
    Calendar c = new GregorianCalendar(zone);
    Quarter q1 = new Quarter(new Date(1017608399999L), zone);
    Quarter q2 = new Quarter(new Date(1017608400000L), zone);

    assertEquals(1, q1.getQuarter());
    assertEquals(1017608399999L, q1.getLastMillisecond(c));

    assertEquals(2, q2.getQuarter());
    assertEquals(1017608400000L, q2.getFirstMillisecond(c));

}
 
Example #16
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Common test setup.
 */
protected void setUp() {
    this.q1Y1900 = new Quarter(1, 1900);
    this.q2Y1900 = new Quarter(2, 1900);
    this.q3Y9999 = new Quarter(3, 9999);
    this.q4Y9999 = new Quarter(4, 9999);
}
 
Example #17
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getStart() method.
 */
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JULY, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Quarter q = new Quarter(3, 2006);
    assertEquals(cal.getTime(), q.getStart());
    Locale.setDefault(saved);
}
 
Example #18
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    Quarter q1 = new Quarter(2, 2003);
    Quarter q2 = new Quarter(2, 2003);
    assertTrue(q1.equals(q2));
    int h1 = q1.hashCode();
    int h2 = q2.hashCode();
    assertEquals(h1, h2);
}
 
Example #19
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L).  Use this
 * to check the quarter constructor.
 */
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Quarter q1 = new Quarter(new Date(1017619199999L), zone);
    Quarter q2 = new Quarter(new Date(1017619200000L), zone);

    assertEquals(1, q1.getQuarter());
    assertEquals(1017619199999L, q1.getLastMillisecond(c));

    assertEquals(2, q2.getQuarter());
    assertEquals(1017619200000L, q2.getFirstMillisecond(c));

}
 
Example #20
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getLastMillisecond() method.
 */
public void testGetLastMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Quarter q = new Quarter(3, 1970);
    assertEquals(23583599999L, q.getLastMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #21
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond() method.
 */
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Quarter q = new Quarter(3, 1970);
    assertEquals(15634800000L, q.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #22
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond() method.
 */
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Quarter q = new Quarter(3, 1970);
    assertEquals(15634800000L, q.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #23
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getLastMillisecond() method.
 */
public void testGetLastMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Quarter q = new Quarter(3, 1970);
    assertEquals(23583599999L, q.getLastMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #24
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getStart() method.
 */
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JULY, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Quarter q = new Quarter(3, 2006);
    assertEquals(cal.getTime(), q.getStart());
    Locale.setDefault(saved);        
}
 
Example #25
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Common test setup.
 */
protected void setUp() {
    this.q1Y1900 = new Quarter(1, 1900);
    this.q2Y1900 = new Quarter(2, 1900);
    this.q3Y9999 = new Quarter(3, 9999);
    this.q4Y9999 = new Quarter(4, 9999);
}
 
Example #26
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getEnd() method.
 */
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.MARCH, 31, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);
    Quarter q = new Quarter(1, 2006);
    assertEquals(cal.getTime(), q.getEnd());
    Locale.setDefault(saved);                
}
 
Example #27
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set up a quarter equal to Q4 9999.  Request the previous quarter, it 
 * should be Q3 9999.
 */
public void testQ4Y9999Previous() {
    Quarter previous = (Quarter) this.q4Y9999.previous();
    assertEquals(this.q3Y9999, previous);
}
 
Example #28
Source File: PeriodAxisTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    PeriodAxis a1 = new PeriodAxis("Test");
    PeriodAxis a2 = new PeriodAxis("Test");
    assertTrue(a1.equals(a2));
    assertTrue(a2.equals(a1));

    a1.setFirst(new Year(2000));
    assertFalse(a1.equals(a2));
    a2.setFirst(new Year(2000));
    assertTrue(a1.equals(a2));

    a1.setLast(new Year(2004));
    assertFalse(a1.equals(a2));
    a2.setLast(new Year(2004));
    assertTrue(a1.equals(a2));

    a1.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
    assertFalse(a1.equals(a2));
    a2.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
    assertTrue(a1.equals(a2));

    a1.setAutoRangeTimePeriodClass(Quarter.class);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeTimePeriodClass(Quarter.class);
    assertTrue(a1.equals(a2));

    PeriodAxisLabelInfo info[] = new PeriodAxisLabelInfo[1];
    info[0] = new PeriodAxisLabelInfo(Month.class,
            new SimpleDateFormat("MMM"));

    a1.setLabelInfo(info);
    assertFalse(a1.equals(a2));
    a2.setLabelInfo(info);
    assertTrue(a1.equals(a2));

    a1.setMajorTickTimePeriodClass(Minute.class);
    assertFalse(a1.equals(a2));
    a2.setMajorTickTimePeriodClass(Minute.class);
    assertTrue(a1.equals(a2));

    a1.setMinorTickMarksVisible(!a1.isMinorTickMarksVisible());
    assertFalse(a1.equals(a2));
    a2.setMinorTickMarksVisible(a1.isMinorTickMarksVisible());
    assertTrue(a1.equals(a2));

    a1.setMinorTickTimePeriodClass(Minute.class);
    assertFalse(a1.equals(a2));
    a2.setMinorTickTimePeriodClass(Minute.class);
    assertTrue(a1.equals(a2));

    Stroke s = new BasicStroke(1.23f);
    a1.setMinorTickMarkStroke(s);
    assertFalse(a1.equals(a2));
    a2.setMinorTickMarkStroke(s);
    assertTrue(a1.equals(a2));

    a1.setMinorTickMarkPaint(Color.blue);
    assertFalse(a1.equals(a2));
    a2.setMinorTickMarkPaint(Color.blue);
    assertTrue(a1.equals(a2));
}
 
Example #29
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set up a quarter equal to Q4 9999.  Request the next quarter, it should 
 * be null.
 */
public void testQ4Y9999Next() {
    Quarter next = (Quarter) this.q4Y9999.next();
    assertNull(next);
}
 
Example #30
Source File: QuarterTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The {@link Quarter} class is immutable, so should not be 
 * {@link Cloneable}.
 */
public void testNotCloneable() {
    Quarter q = new Quarter(2, 2003);
    assertFalse(q instanceof Cloneable);
}