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

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Returns the year.

Usage

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

/**
 * Set up a year equal to 1900.  Request the next year, it should be 1901.
 */// w  ww.j  a  v a2  s.  co  m
@Test
public void test1900Next() {
    Year current = new Year(1900);
    Year next = (Year) current.next();
    assertEquals(1901, next.getYear());
}

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

/**
 * Set up a year equal to 9999.  Request the previous year, it should be
 * 9998.//from w  w  w .  ja  v  a 2  s .  co  m
 */
@Test
public void test9999Previous() {
    Year current = new Year(9999);
    Year previous = (Year) current.previous();
    assertEquals(9998, previous.getYear());
}

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

/**
 * Some checks for the testNext() method.
 *//*from  w ww.ja  va  2s .  c o m*/
@Test
public void testNext() {
    Year y = new Year(2000);
    y = (Year) y.next();
    assertEquals(2001, y.getYear());
    y = new Year(9999);
    assertNull(y.next());
}

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

/**
 * In GMT, the end of 2001 is java.util.Date(1009843199999L).  Use this to
 * check the year constructor./* www  .ja  v  a 2  s  . com*/
 */
@Test
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Date d1 = new Date(1009843199999L);
    Date d2 = new Date(1009843200000L);
    Year y1 = new Year(d1, zone);
    Year y2 = new Year(d2, zone);

    assertEquals(2001, y1.getYear());
    assertEquals(1009843199999L, y1.getLastMillisecond(zone));

    assertEquals(2002, y2.getYear());
    assertEquals(1009843200000L, y2.getFirstMillisecond(zone));

}

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

/**
 * In Los Angeles, the end of 2001 is java.util.Date(1009871999999L).  Use
 * this to check the year constructor.//from  www  .  j a  v  a 2  s.  c o m
 */
@Test
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Year y1 = new Year(new Date(1009871999999L), zone);
    Year y2 = new Year(new Date(1009872000000L), zone);

    assertEquals(2001, y1.getYear());
    assertEquals(1009871999999L, y1.getLastMillisecond(zone));

    assertEquals(2002, y2.getYear());
    assertEquals(1009872000000L, y2.getFirstMillisecond(zone));

}

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

/**
 * Tests the year string parser./*from   w w  w. ja  v a2  s  . c o  m*/
 */
@Test
public void testParseYear() {

    Year year = null;

    // test 1...
    try {
        year = Year.parseYear("2000");
    } catch (TimePeriodFormatException e) {
        year = new Year(1900);
    }
    assertEquals(2000, year.getYear());

    // test 2...
    try {
        year = Year.parseYear(" 2001 ");
    } catch (TimePeriodFormatException e) {
        year = new Year(1900);
    }
    assertEquals(2001, year.getYear());

    // test 3...
    try {
        year = Year.parseYear("99");
    } catch (TimePeriodFormatException e) {
        year = new Year(1900);
    }
    assertEquals(99, year.getYear());

}

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

/**
 * Constructs a new quarter.//  ww  w.  j  a v a  2 s. com
 *
 * @param quarter  the quarter (1 to 4).
 * @param year  the year (1900 to 9999).
 */
public Quarter(int quarter, Year year) {
    if ((quarter < FIRST_QUARTER) || (quarter > LAST_QUARTER)) {
        throw new IllegalArgumentException("Quarter outside valid range.");
    }
    this.year = (short) year.getYear();
    this.quarter = (byte) quarter;
    peg(Calendar.getInstance());
}

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

/**
 * Constructs a new month instance.//from   ww  w.  jav  a 2  s  .  co  m
 *
 * @param month  the month (in the range 1 to 12).
 * @param year  the year.
 */
public Month(int month, Year year) {
    if ((month < 1) || (month > 12)) {
        throw new IllegalArgumentException("Month outside valid range.");
    }
    this.month = month;
    this.year = year.getYear();
    peg(Calendar.getInstance());
}

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

/**
 * Creates a time period representing the week in the specified year.
 *
 * @param week  the week (1 to 53)./*  w  w w.  j  a va2  s  . c  o m*/
 * @param year  the year (1900 to 9999).
 */
public Week(int week, Year year) {
    if ((week < FIRST_WEEK_IN_YEAR) && (week > LAST_WEEK_IN_YEAR)) {
        throw new IllegalArgumentException("The 'week' argument must be in the range 1 - 53.");
    }
    this.week = (byte) week;
    this.year = (short) year.getYear();
    peg(Calendar.getInstance());
}