org.jfree.data.time.Second Java Examples

The following examples show how to use org.jfree.data.time.Second. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithTimeZone() {
    Second s = new Second(50, 59, 15, 1, 4, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-623289610000L, s.getFirstMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        s.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #2
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithCalendar() {
    Second s = new Second(55, 40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766455000L, s.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        s.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #3
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithTimeZone() {
    Second s = new Second(55, 1, 2, 7, 7, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-614962684001L, s.getLastMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        s.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #4
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Second s = new Second(50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550999L, s.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        s.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #5
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithTimeZone() {
    Second s = new Second(50, 59, 15, 1, 4, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-623289610000L, s.getFirstMillisecond(c));
    
    // try null calendar
    boolean pass = false;
    try {
        s.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);            
}
 
Example #6
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 */
public void testGetFirstMillisecondWithCalendar() {
    Second s = new Second(55, 40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766455000L, s.getFirstMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        s.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #7
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithTimeZone() {
    Second s = new Second(55, 1, 2, 7, 7, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-614962684001L, s.getLastMillisecond(c));
    
    // try null calendar
    boolean pass = false;
    try {
        s.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);            
}
 
Example #8
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Second s = new Second(50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550999L, s.getLastMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        s.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #9
protected int getDateUnitAsInt( final Class domainTimePeriod ) {
  if ( Second.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.SECOND;
  }
  if ( Minute.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MINUTE;
  }
  if ( Hour.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.HOUR;
  }
  if ( Day.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.DAY;
  }
  if ( Month.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MONTH;
  }
  if ( Year.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.YEAR;
  }
  if ( Second.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MILLISECOND;
  }
  return DateTickUnit.DAY;
}
 
Example #10
protected int getDateUnitAsInt( final Class domainTimePeriod ) {
  if ( Second.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.SECOND;
  }
  if ( Minute.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MINUTE;
  }
  if ( Hour.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.HOUR;
  }
  if ( Day.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.DAY;
  }
  if ( Month.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MONTH;
  }
  if ( Year.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.YEAR;
  }
  if ( Second.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MILLISECOND;
  }
  return DateTickUnit.DAY;
}
 
Example #11
Source Project: pentaho-reporting   Author: pentaho   File: XYChartExpression.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private int getDateUnitAsInt( final Class domainTimePeriod ) {
  if ( Second.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.SECOND;
  }
  if ( Minute.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MINUTE;
  }
  if ( Hour.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.HOUR;
  }
  if ( Day.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.DAY;
  }
  if ( Month.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MONTH;
  }
  if ( Year.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.YEAR;
  }
  if ( Second.class.equals( domainTimePeriod ) ) {
    return DateTickUnit.MILLISECOND;
  }
  return DateTickUnit.DAY;
}
 
Example #12
Source Project: pentaho-reporting   Author: pentaho   File: ChartConstants.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Class getTimePeriodClass( final String timePeriodStr ) {
  Class retClass = Millisecond.class;
  if ( timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR ) ) {
    retClass = Second.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR ) ) {
    retClass = Minute.class;
  } else if ( timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR ) ) {
    retClass = Hour.class;
  } else if ( timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR ) ) {
    retClass = Day.class;
  } else if ( timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR ) ) {
    retClass = Week.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR ) ) {
    retClass = Month.class;
  } else if ( timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR ) ) {
    retClass = Quarter.class;
  } else if ( timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR ) ) {
    retClass = Year.class;
  }
  return retClass;
}
 
Example #13
private static Class getTimePeriodClass( final String timePeriodStr ) {
  Class retClass = Millisecond.class;
  if ( timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR ) ) {
    retClass = Second.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR ) ) {
    retClass = Minute.class;
  } else if ( timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR ) ) {
    retClass = Hour.class;
  } else if ( timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR ) ) {
    retClass = Day.class;
  } else if ( timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR ) ) {
    retClass = Week.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR ) ) {
    retClass = Month.class;
  } else if ( timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR ) ) {
    retClass = Quarter.class;
  } else if ( timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR ) ) {
    retClass = Year.class;
  }
  return retClass;
}
 
Example #14
Source Project: amodeus   Author: amodeus-science   File: StaticHelperTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testToTime() {
    Random random = new Random();
    int hour = random.nextInt(696);
    int minute = random.nextInt(60);
    int second = random.nextInt(60);
    int year = Calendar.getInstance().get(Calendar.YEAR);
    int month = Calendar.getInstance().get(Calendar.MONTH) + 1; // Month are 0 based, thus it is necessary to add 1
    Second expected = new Second(second, minute, hour % 24, hour / 24 + 1, month, year);
    Scalar time = RealScalar.of((hour * 60 + minute) * 60 + second);

    Second resulting = StaticHelper.toTime(time);
    assertEquals(expected.toString(), resulting.toString());
}
 
Example #15
Source Project: doov   Author: doov-io   File: BenchmarkUI.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    final TimeSeriesCollection dataSet = new TimeSeriesCollection();
    final TimeSeries series_doov = new TimeSeries("dOOv");
    final TimeSeries series_bareMetal = new TimeSeries("Bare Metal");
    final TimeSeries series_beanValidation = new TimeSeries("Bean Validation - HV 6.0.7");
    dataSet.addSeries(series_doov);
    dataSet.addSeries(series_bareMetal);
    dataSet.addSeries(series_beanValidation);

    final JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.setSize(new Dimension(1280, 1024));
    f.getContentPane().add(new ChartPanel(createTimeSeriesChart("dOOv benchmark", "time", "hits", dataSet)), BorderLayout.CENTER);
    f.setVisible(true);

    final BareMetalRunnable bareRunnable = new BareMetalRunnable();
    final DoovRunnable doovRunnable = new DoovRunnable();
    final BeanValidationRunnable beanValidationRunnable = new BeanValidationRunnable();
    new Thread(beanValidationRunnable).start();
    new Thread(bareRunnable).start();
    new Thread(doovRunnable).start();

    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            SwingUtilities.invokeLater(() -> {
                final Second second = new Second();
                series_doov.addOrUpdate(second, doovRunnable.hits.get());
                series_bareMetal.addOrUpdate(second, bareRunnable.hits.get());
                series_beanValidation.addOrUpdate(second, beanValidationRunnable.hits.get());
            });
        }
    }, 0, 200);
}
 
Example #16
Source Project: TAcharting   Author: team172011   File: ChartIndicator.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Extracts a {@link org.jfree.data.time.TimeSeries Collection of jfreeCharts TimeSeries} for plotting this
 * ChartIndicator
 * @return a TimeSeriesCollection
 * @throws ClassCastException if the generic type of {@link ChartIndicator} is not in bounds of {@link Num} interface
 */
public TimeSeriesCollection getDataSet(){
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    for(int index = 0; index< this.getIndicatorsCount(); index++){
        Indicator<Type> indicator = this.getIndicator(index);
        org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries(this.getName(index));
        
        for(int i = 0; i<indicator.getBarSeries().getBarCount(); i++){
            Bar t = indicator.getBarSeries().getBar(i);
            chartTimeSeries.add(new Second(new Date(t.getEndTime().toEpochSecond() * 1000)), ((Num)indicator.getValue(i)).doubleValue());
        }
        dataset.addSeries(chartTimeSeries);
    }
    return dataset;
}
 
Example #17
Source Project: astor   Author: SpoonLabs   File: MillisecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests the equals method.
 */
public void testEquals() {
    Day day1 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour1 = new Hour(15, day1);
    Minute minute1 = new Minute(15, hour1);
    Second second1 = new Second(34, minute1);
    Millisecond milli1 = new Millisecond(999, second1);
    Day day2 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour2 = new Hour(15, day2);
    Minute minute2 = new Minute(15, hour2);
    Second second2 = new Second(34, minute2);
    Millisecond milli2 = new Millisecond(999, second2);
    assertTrue(milli1.equals(milli2));
}
 
Example #18
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests the equals method.
 */
public void testEquals() {
    Day day1 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour1 = new Hour(15, day1);
    Minute minute1 = new Minute(15, hour1);
    Second second1 = new Second(34, minute1);
    Day day2 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour2 = new Hour(15, day2);
    Minute minute2 = new Minute(15, hour2);
    Second second2 = new Second(34, minute2);
    assertTrue(second1.equals(second2));
}
 
Example #19
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * In GMT, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016729759000L).
 * Use this to check the Second constructor.
 */
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Second s1 = new Second(new Date(1016729758999L), zone);
    Second s2 = new Second(new Date(1016729759000L), zone);

    assertEquals(58, s1.getSecond());
    assertEquals(1016729758999L, s1.getLastMillisecond(c));

    assertEquals(59, s2.getSecond());
    assertEquals(1016729759000L, s2.getFirstMillisecond(c));

}
 
Example #20
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * In Chicago, the 4.55:59pm on 21 Mar 2002 is
 * java.util.Date(1016751359000L). Use this to check the Second constructor.
 */
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("America/Chicago");
    Calendar c = new GregorianCalendar(zone);
    Second s1 = new Second(new Date(1016751358999L), zone);
    Second s2 = new Second(new Date(1016751359000L), zone);

    assertEquals(58, s1.getSecond());
    assertEquals(1016751358999L, s1.getLastMillisecond(c));

    assertEquals(59, s2.getSecond());
    assertEquals(1016751359000L, s2.getFirstMillisecond(c));

}
 
Example #21
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    Second s1 = new Second(13, 45, 5, 1, 2, 2003);
    Second s2 = new Second(13, 45, 5, 1, 2, 2003);
    assertTrue(s1.equals(s2));
    int h1 = s1.hashCode();
    int h2 = s2.hashCode();
    assertEquals(h1, h2);
}
 
Example #22
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond() method.
 */
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Second s = new Second(15, 43, 15, 1, 4, 2006);
    assertEquals(1143902595000L, s.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #23
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getLastMillisecond() method.
 */
public void testGetLastMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Second s = new Second(1, 1, 1, 1, 1, 1970);
    assertEquals(61999L, s.getLastMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #24
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getStart() method.
 */
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 0);
    Second s = new Second(55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), s.getStart());
    Locale.setDefault(saved);
}
 
Example #25
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getEnd() method.
 */
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 999);
    Second s = new Second(55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), s.getEnd());
    Locale.setDefault(saved);
}
 
Example #26
Source Project: astor   Author: SpoonLabs   File: MillisecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests the equals method.
 */
public void testEquals() {
    Day day1 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour1 = new Hour(15, day1);
    Minute minute1 = new Minute(15, hour1);
    Second second1 = new Second(34, minute1);
    Millisecond milli1 = new Millisecond(999, second1);
    Day day2 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour2 = new Hour(15, day2);
    Minute minute2 = new Minute(15, hour2);
    Second second2 = new Second(34, minute2);
    Millisecond milli2 = new Millisecond(999, second2);
    assertTrue(milli1.equals(milli2));
}
 
Example #27
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests the equals method.
 */
public void testEquals() {
    Day day1 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour1 = new Hour(15, day1);
    Minute minute1 = new Minute(15, hour1);
    Second second1 = new Second(34, minute1);
    Day day2 = new Day(29, MonthConstants.MARCH, 2002);
    Hour hour2 = new Hour(15, day2);
    Minute minute2 = new Minute(15, hour2);
    Second second2 = new Second(34, minute2);
    assertTrue(second1.equals(second2));
}
 
Example #28
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * In GMT, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016729759000L).
 * Use this to check the Second constructor.
 */
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Second s1 = new Second(new Date(1016729758999L), zone);
    Second s2 = new Second(new Date(1016729759000L), zone);

    assertEquals(58, s1.getSecond());
    assertEquals(1016729758999L, s1.getLastMillisecond(c));

    assertEquals(59, s2.getSecond());
    assertEquals(1016729759000L, s2.getFirstMillisecond(c));

}
 
Example #29
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * In Chicago, the 4.55:59pm on 21 Mar 2002 is 
 * java.util.Date(1016751359000L). Use this to check the Second constructor.
 */
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("America/Chicago");
    Calendar c = new GregorianCalendar(zone);
    Second s1 = new Second(new Date(1016751358999L), zone);
    Second s2 = new Second(new Date(1016751359000L), zone);

    assertEquals(58, s1.getSecond());
    assertEquals(1016751358999L, s1.getLastMillisecond(c));

    assertEquals(59, s2.getSecond());
    assertEquals(1016751359000L, s2.getFirstMillisecond(c));

}
 
Example #30
Source Project: astor   Author: SpoonLabs   File: SecondTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    Second s1 = new Second(13, 45, 5, 1, 2, 2003);
    Second s2 = new Second(13, 45, 5, 1, 2, 2003);
    assertTrue(s1.equals(s2));
    int h1 = s1.hashCode();
    int h2 = s2.hashCode();
    assertEquals(h1, h2);
}