List of usage examples for org.apache.commons.lang3.time DateUtils addSeconds
public static Date addSeconds(final Date date, final int amount)
From source file:ubic.gemma.core.analysis.preprocess.batcheffects.BatchInfoPopulationServiceTest.java
@Test public void testDatesToBatchB() { BatchInfoPopulationHelperServiceImpl ser = new BatchInfoPopulationHelperServiceImpl(); Calendar cal = Calendar.getInstance(); cal.set(2004, Calendar.APRIL, 10); Date d = cal.getTime();/*w w w.j av a 2s .c o m*/ Collection<Date> dates = new HashSet<>(); dates.add(d); dates.add(DateUtils.addSeconds(d, 3500));// first batch, all within two hours of each other. dates.add(DateUtils.addSeconds(d, 7000));// first batch, all within two hours of each other. dates.add(DateUtils.addSeconds(d, 8000));// first batch, all within two hours of each other. dates.add(DateUtils.addHours(d, 2226));// second batch, but singleton merged backwards dates.add(DateUtils.addHours(d, 11124));// third batch , but second was a singleton so we're only on #2. dates.add(DateUtils.addHours(d, 11125));// third batch, but gets merged in with second. dates.add(DateUtils.addHours(d, 11189)); // fourth batch, but gets merged in with second. Map<String, Collection<Date>> actual = ser.convertDatesToBatches(dates); /* * How many unique values? */ Set<String> s = new HashSet<>(actual.keySet()); assertEquals(2, s.size()); this.debug(actual); }