Example usage for org.jfree.data.time SimpleTimePeriod compareTo

List of usage examples for org.jfree.data.time SimpleTimePeriod compareTo

Introduction

In this page you can find the example usage for org.jfree.data.time SimpleTimePeriod compareTo.

Prototype

@Override
public int compareTo(Object obj) 

Source Link

Document

Returns an integer that indicates the relative ordering of two time periods.

Usage

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

/**
 * Some checks for the compareTo() method.
 *//*  ww w  .  j  a  v  a2 s. c o  m*/
@Test
public void testCompareTo() {
    SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    SimpleTimePeriod s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(0, s1.compareTo(s2));

    s1 = new SimpleTimePeriod(new Date(9L), new Date(21L));
    s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(-1, s1.compareTo(s2));

    s1 = new SimpleTimePeriod(new Date(11L), new Date(19L));
    s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(1, s1.compareTo(s2));

    s1 = new SimpleTimePeriod(new Date(9L), new Date(19L));
    s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(-1, s1.compareTo(s2));

    s1 = new SimpleTimePeriod(new Date(11L), new Date(21));
    s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(1, s1.compareTo(s2));

    s1 = new SimpleTimePeriod(new Date(10L), new Date(18));
    s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(-1, s1.compareTo(s2));

    s1 = new SimpleTimePeriod(new Date(10L), new Date(22));
    s2 = new SimpleTimePeriod(new Date(10L), new Date(20L));
    assertEquals(1, s1.compareTo(s2));
}