Example usage for org.jfree.data.time Millisecond getFirstMillisecond

List of usage examples for org.jfree.data.time Millisecond getFirstMillisecond

Introduction

In this page you can find the example usage for org.jfree.data.time Millisecond getFirstMillisecond.

Prototype

@Override
public long getFirstMillisecond(Calendar calendar) 

Source Link

Document

Returns the first millisecond of the time period.

Usage

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *///  w w w .  jav  a 2  s.  com
@Test
public void testGetFirstMillisecondWithTimeZone() {
    Millisecond m = new Millisecond(500, 50, 59, 15, 1, 4, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    assertEquals(-623289609500L, m.getFirstMillisecond(zone));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((TimeZone) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *//*from  w w  w  .  jav  a 2s  . c  o m*/
@Test
public void testGetFirstMillisecondWithCalendar() {
    Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766455500L, m.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *///  www .  ja  va  2 s.com
public void testGetFirstMillisecondWithTimeZone() {
    Millisecond m = new Millisecond(500, 50, 59, 15, 1, 4, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-623289609500L, m.getFirstMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * In GMT, the 4.55:59.123pm on 21 Mar 2002 is
 * java.util.Date(1016729759123L).  Use this to check the Millisecond
 * constructor./*from  w  w  w. j a va 2  s  .  c om*/
 */
@Test
public void testDateConstructor1() {
    TimeZone zone = TimeZone.getTimeZone("GMT");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Millisecond m1 = new Millisecond(new Date(1016729759122L), zone, locale);
    Millisecond m2 = new Millisecond(new Date(1016729759123L), zone, locale);

    assertEquals(122, m1.getMillisecond());
    assertEquals(1016729759122L, m1.getLastMillisecond(zone));

    assertEquals(123, m2.getMillisecond());
    assertEquals(1016729759123L, m2.getFirstMillisecond(zone));
}

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

/**
 * In Tallinn, the 4.55:59.123pm on 21 Mar 2002 is
 * java.util.Date(1016722559123L).  Use this to check the Millisecond
 * constructor./*from w w w.  j a  v  a 2s  . c om*/
 */
@Test
public void testDateConstructor2() {
    TimeZone zone = TimeZone.getTimeZone("Europe/Tallinn");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Millisecond m1 = new Millisecond(new Date(1016722559122L), zone, locale);
    Millisecond m2 = new Millisecond(new Date(1016722559123L), zone, locale);

    assertEquals(122, m1.getMillisecond());
    assertEquals(1016722559122L, m1.getLastMillisecond(zone));

    assertEquals(123, m2.getMillisecond());
    assertEquals(1016722559123L, m2.getFirstMillisecond(zone));
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *//*w  w w . j  a  v  a2 s .  c o m*/
public void testGetFirstMillisecondWithCalendar() {
    Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766455500L, m.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * In GMT, the 4.55:59.123pm on 21 Mar 2002 is
 * java.util.Date(1016729759123L).  Use this to check the Millisecond
 * constructor./*from w  w  w  . j a  v a 2  s .  co m*/
 */
public void testDateConstructor1() {
    TimeZone zone = TimeZone.getTimeZone("GMT");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Calendar c = new GregorianCalendar(zone);
    Millisecond m1 = new Millisecond(new Date(1016729759122L), zone, locale);
    Millisecond m2 = new Millisecond(new Date(1016729759123L), zone, locale);

    assertEquals(122, m1.getMillisecond());
    assertEquals(1016729759122L, m1.getLastMillisecond(c));

    assertEquals(123, m2.getMillisecond());
    assertEquals(1016729759123L, m2.getFirstMillisecond(c));
}

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

/**
 * In Tallinn, the 4.55:59.123pm on 21 Mar 2002 is
 * java.util.Date(1016722559123L).  Use this to check the Millisecond
 * constructor.//from  w w w.  j a  va  2  s  . c  om
 */
public void testDateConstructor2() {
    TimeZone zone = TimeZone.getTimeZone("Europe/Tallinn");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Calendar c = new GregorianCalendar(zone);
    Millisecond m1 = new Millisecond(new Date(1016722559122L), zone, locale);
    Millisecond m2 = new Millisecond(new Date(1016722559123L), zone, locale);

    assertEquals(122, m1.getMillisecond());
    assertEquals(1016722559122L, m1.getLastMillisecond(c));

    assertEquals(123, m2.getMillisecond());
    assertEquals(1016722559123L, m2.getFirstMillisecond(c));
}