Example usage for org.jfree.data.time Month parseMonth

List of usage examples for org.jfree.data.time Month parseMonth

Introduction

In this page you can find the example usage for org.jfree.data.time Month parseMonth.

Prototype

public static Month parseMonth(String s) 

Source Link

Document

Parses the string argument as a month.

Usage

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

/**
 * Tests the string parsing code...//w  w  w  .  ja v  a 2s .c  o  m
 */
@Test
public void testParseMonth() {

    Month month = null;

    // test 1...
    try {
        month = Month.parseMonth("1990-01");
    } catch (TimePeriodFormatException e) {
        month = new Month(1, 1900);
    }
    assertEquals(1, month.getMonth());
    assertEquals(1990, month.getYear().getYear());

    // test 2...
    try {
        month = Month.parseMonth("02-1991");
    } catch (TimePeriodFormatException e) {
        month = new Month(1, 1900);
    }
    assertEquals(2, month.getMonth());
    assertEquals(1991, month.getYear().getYear());

    // test 3...
    try {
        month = Month.parseMonth("March 1993");
    } catch (TimePeriodFormatException e) {
        month = new Month(1, 1900);
    }
    assertEquals(3, month.getMonth());
    assertEquals(1993, month.getYear().getYear());

}

From source file:org.jfree.data.time.junit.MonthTest.java

/**
 * Tests the string parsing code.../*from w  ww  .j  a va  2  s.com*/
 */
public void testParseMonth() {

    Month month;

    // test 1...
    try {
        month = Month.parseMonth("1990-01");
    } catch (TimePeriodFormatException e) {
        month = new Month(1, 1900);
    }
    assertEquals(1, month.getMonth());
    assertEquals(1990, month.getYear().getYear());

    // test 2...
    try {
        month = Month.parseMonth("02-1991");
    } catch (TimePeriodFormatException e) {
        month = new Month(1, 1900);
    }
    assertEquals(2, month.getMonth());
    assertEquals(1991, month.getYear().getYear());

    // test 3...
    try {
        month = Month.parseMonth("March 1993");
    } catch (TimePeriodFormatException e) {
        month = new Month(1, 1900);
    }
    assertEquals(3, month.getMonth());
    assertEquals(1993, month.getYear().getYear());

}