Package org.jfree.data.time

Examples of org.jfree.data.time.Quarter


    /**
     * Tests the equals method.
     */
    public void testEquals() {
        final Quarter q1 = new Quarter(2, 2002);
        final Quarter q2 = new Quarter(2, 2002);
        assertTrue(q1.equals(q2));
    }
View Full Code Here


     * quarter constructor.
     */
    public void testDateConstructor1() {

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

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

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

    }
View Full Code Here

     * quarter constructor.
     */
    public void testDateConstructor2() {

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

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

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

    }
View Full Code Here

    /**
     * Set up a quarter equal to Q1 1900.  Request the previous quarter, it should be null.
     */
    public void testQ1Y1900Previous() {
        final Quarter previous = (Quarter) this.q1Y1900.previous();
        assertNull(previous);
    }
View Full Code Here

    /**
     * Set up a quarter equal to Q1 1900.  Request the next quarter, it should be Q2 1900.
     */
    public void testQ1Y1900Next() {
        final Quarter next = (Quarter) this.q1Y1900.next();
        assertEquals(this.q2Y1900, next);
    }
View Full Code Here

    /**
     * Set up a quarter equal to Q4 9999.  Request the previous quarter, it should be Q3 9999.
     */
    public void testQ4Y9999Previous() {
        final Quarter previous = (Quarter) this.q4Y9999.previous();
        assertEquals(this.q3Y9999, previous);
    }
View Full Code Here

    /**
     * Set up a quarter equal to Q4 9999.  Request the next quarter, it should be null.
     */
    public void testQ4Y9999Next() {
        final Quarter next = (Quarter) this.q4Y9999.next();
        assertNull(next);
    }
View Full Code Here

    /**
     * Test the string parsing code...
     */
    public void testParseQuarter() {

        Quarter quarter = null;

        // test 1...
        try {
            quarter = Quarter.parseQuarter("Q1-2000");
        }
        catch (TimePeriodFormatException e) {
            quarter = new Quarter(1, 1900);
        }
        assertEquals(1, quarter.getQuarter());
        assertEquals(2000, quarter.getYear().getYear());

        // test 2...
        try {
            quarter = Quarter.parseQuarter("2001-Q2");
        }
        catch (TimePeriodFormatException e) {
            quarter = new Quarter(1, 1900);
        }
        assertEquals(2, quarter.getQuarter());
        assertEquals(2001, quarter.getYear().getYear());

        // test 3...
        try {
            quarter = Quarter.parseQuarter("Q3, 2002");
        }
        catch (TimePeriodFormatException e) {
            quarter = new Quarter(1, 1900);
        }
        assertEquals(3, quarter.getQuarter());
        assertEquals(2002, quarter.getYear().getYear());

    }
View Full Code Here

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        final Quarter q1 = new Quarter(4, 1999);
        Quarter q2 = null;

        try {
            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            final ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(q1);
View Full Code Here

   
    /**
     * Two objects that are equal are required to return the same hashCode.
     */
    public void testHashcode() {
        final Quarter q1 = new Quarter(2, 2003);
        final Quarter q2 = new Quarter(2, 2003);
        assertTrue(q1.equals(q2));
        final int h1 = q1.hashCode();
        final int h2 = q2.hashCode();
        assertEquals(h1, h2);
    }
View Full Code Here

TOP

Related Classes of org.jfree.data.time.Quarter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.