Example usage for org.jfree.data.time Week getYear

List of usage examples for org.jfree.data.time Week getYear

Introduction

In this page you can find the example usage for org.jfree.data.time Week getYear.

Prototype

public Year getYear() 

Source Link

Document

Returns the year in which the week falls.

Usage

From source file:org.jfree.data.time.WeekTest.java

/**
 * Some checks for the testNext() method.
 *///from   w  w  w  .j  a v  a  2 s.  c  om
@Test
public void testNext() {
    Week w = new Week(12, 2000);
    w = (Week) w.next();
    assertEquals(new Year(2000), w.getYear());
    assertEquals(13, w.getWeek());
    w = new Week(53, 9999);
    assertNull(w.next());
}

From source file:org.jfree.data.time.WeekTest.java

/**
 * A test case for bug 1498805./*from w ww.  j  a va  2s.  co  m*/
 */
@Test
public void testBug1498805() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    try {
        TimeZone zone = TimeZone.getTimeZone("GMT");
        GregorianCalendar gc = new GregorianCalendar(zone);
        gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);
        Week w = new Week(gc.getTime(), zone);
        assertEquals(53, w.getWeek());
        assertEquals(new Year(2004), w.getYear());
    } finally {
        Locale.setDefault(saved);
    }
}

From source file:org.jfree.data.time.Week.java

/**
 * Returns an integer indicating the order of this Week object relative to
 * the specified object:/*  w ww .  ja va2 s.  c o  m*/
 *
 * negative == before, zero == same, positive == after.
 *
 * @param o1  the object to compare.
 *
 * @return negative == before, zero == same, positive == after.
 */
@Override
public int compareTo(Object o1) {

    int result;

    // CASE 1 : Comparing to another Week object
    // --------------------------------------------
    if (o1 instanceof Week) {
        Week w = (Week) o1;
        result = this.year - w.getYear().getYear();
        if (result == 0) {
            result = this.week - w.getWeek();
        }
    }

    // CASE 2 : Comparing to another TimePeriod object
    // -----------------------------------------------
    else if (o1 instanceof RegularTimePeriod) {
        // more difficult case - evaluate later...
        result = 0;
    }

    // CASE 3 : Comparing to a non-TimePeriod object
    // ---------------------------------------------
    else {
        // consider time periods to be ordered after general objects
        result = 1;
    }

    return result;

}