List of usage examples for org.jfree.data.time Hour getHour
public int getHour()
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. *//*from w ww.java 2 s.c o 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 av 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)); }
From source file:org.jfree.data.time.HourTest.java
/** * Some checks for the testNext() method. *//*ww w . ja v a 2 s .c om*/ @Test public void testNext() { Hour h = new Hour(1, 12, 12, 2000); h = (Hour) h.next(); assertEquals(2000, h.getYear()); assertEquals(12, h.getMonth()); assertEquals(12, h.getDayOfMonth()); assertEquals(2, h.getHour()); h = new Hour(23, 31, 12, 9999); assertNull(h.next()); }
From source file:org.jfree.data.time.junit.HourTest.java
/** * Some checks for the testNext() method. *///from w w w. j a va2 s.c o m public void testNext() { Hour h = new Hour(1, 12, 12, 2000); h = (Hour) h.next(); assertEquals(2000, h.getYear()); assertEquals(12, h.getMonth()); assertEquals(12, h.getDayOfMonth()); assertEquals(2, h.getHour()); h = new Hour(23, 31, 12, 9999); assertNull(h.next()); }
From source file:org.jfree.data.time.Minute.java
/** * Constructs a new Minute.//from w w w . j ava 2 s .c o m * * @param minute the minute (0 to 59). * @param hour the hour (<code>null</code> not permitted). */ public Minute(int minute, Hour hour) { ParamChecks.nullNotPermitted(hour, "hour"); this.minute = (byte) minute; this.hour = (byte) hour.getHour(); this.day = hour.getDay(); peg(Calendar.getInstance()); }
From source file:org.jfree.data.time.Hour.java
/** * Returns an integer indicating the order of this Hour object relative to * the specified object:// w w w . j a v a 2 s .co m * * negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ @Override public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Hour object // ----------------------------------------- if (o1 instanceof Hour) { Hour h = (Hour) o1; result = getDay().compareTo(h.getDay()); if (result == 0) { result = this.hour - h.getHour(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; }