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

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

Introduction

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

Prototype

@Override
public long getFirstMillisecond(Calendar calendar) 

Source Link

Document

Returns the first millisecond of the hour.

Usage

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *//*from   w  ww  .j a v a  2 s .c  o m*/
@Test
public void testGetFirstMillisecondWithTimeZone() {
    Hour h = new Hour(15, 1, 4, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    assertEquals(-623293200000L, h.getFirstMillisecond(zone));

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

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *///from   w  w  w.j  a  v a  2 s  .  com
public void testGetFirstMillisecondWithTimeZone() {
    Hour h = new Hour(15, 1, 4, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-623293200000L, h.getFirstMillisecond(c));

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

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *//*from  w w  w  .ja  v a 2s  .c om*/
@Test
public void testGetFirstMillisecondWithCalendar() {
    Hour h = new Hour(2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955764000000L, h.getFirstMillisecond(calendar));

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

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

/**
 * In GMT, the 4pm on 21 Mar 2002 is java.util.Date(1,014,307,200,000L).
 * Use this to check the hour constructor.
 */// w ww  .  ja v  a2s.  com
@Test
public void testDateConstructor1() {
    TimeZone zone = TimeZone.getTimeZone("GMT");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Hour h1 = new Hour(new Date(1014307199999L), zone, locale);
    Hour h2 = new Hour(new Date(1014307200000L), zone, locale);

    assertEquals(15, h1.getHour());
    assertEquals(1014307199999L, h1.getLastMillisecond(zone));

    assertEquals(16, h2.getHour());
    assertEquals(1014307200000L, h2.getFirstMillisecond(zone));
}

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

/**
 * In Sydney, the 4pm on 21 Mar 2002 is java.util.Date(1,014,267,600,000L).
 * Use this to check the hour constructor.
 *//*from  w  w  w.  j  a  v a  2  s . c  o m*/
@Test
public void testDateConstructor2() {
    TimeZone zone = TimeZone.getTimeZone("Australia/Sydney");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Hour h1 = new Hour(new Date(1014267599999L), zone, locale);
    Hour h2 = new Hour(new Date(1014267600000L), zone, locale);

    assertEquals(15, h1.getHour());
    assertEquals(1014267599999L, h1.getLastMillisecond(zone));

    assertEquals(16, h2.getHour());
    assertEquals(1014267600000L, h2.getFirstMillisecond(zone));
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *///from  w  ww.j  a  va 2  s.  c o m
public void testGetFirstMillisecondWithCalendar() {
    Hour h = new Hour(2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955764000000L, h.getFirstMillisecond(calendar));

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

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

/**
 * In GMT, the 4pm on 21 Mar 2002 is java.util.Date(1,014,307,200,000L).
 * Use this to check the hour constructor.
 *///ww w . j  ava2s .  co m
public void testDateConstructor1() {
    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Locale locale = Locale.getDefault(); // locale should not matter here
    Hour h1 = new Hour(new Date(1014307199999L), zone, locale);
    Hour h2 = new Hour(new Date(1014307200000L), zone, locale);

    assertEquals(15, h1.getHour());
    assertEquals(1014307199999L, h1.getLastMillisecond(c));

    assertEquals(16, h2.getHour());
    assertEquals(1014307200000L, h2.getFirstMillisecond(c));
}

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

/**
 * In Sydney, the 4pm on 21 Mar 2002 is java.util.Date(1,014,267,600,000L).
 * Use this to check the hour constructor.
 *//*from  w  w w . j  a v a  2  s . co  m*/
public void testDateConstructor2() {
    TimeZone zone = TimeZone.getTimeZone("Australia/Sydney");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Calendar c = new GregorianCalendar(zone);
    Hour h1 = new Hour(new Date(1014267599999L), zone, locale);
    Hour h2 = new Hour(new Date(1014267600000L), zone, locale);

    assertEquals(15, h1.getHour());
    assertEquals(1014267599999L, h1.getLastMillisecond(c));

    assertEquals(16, h2.getHour());
    assertEquals(1014267600000L, h2.getFirstMillisecond(c));
}