Java Code Examples for com.ibm.icu.util.Calendar#set()

The following examples show how to use com.ibm.icu.util.Calendar#set() . 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 File: ServerHitBin.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
private static long getEvenStartingTime(long binLength) {
    // binLengths should be a divisable evenly into 1 hour
    long curTime = System.currentTimeMillis();

    // find the first previous millis that are even on the hour
    Calendar cal = Calendar.getInstance();

    cal.setTime(new Date(curTime));
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);

    while (cal.getTime().getTime() < (curTime - binLength)) {
        cal.add(Calendar.MILLISECOND, (int) binLength);
    }

    return cal.getTime().getTime();
}
 
Example 2
Source File: TimeMemberUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param d
 * @return
 */
private static Calendar getCalendar( Date d )
{
	Calendar c = Calendar.getInstance( timeZone, defaultLocale );
	
	if ( d == null )
	{
		c.clear( );
		c.set( 1970, 0, 1 );
	}
	else
	{
		c.setTime( d );
	}
	return c;
}
 
Example 3
Source File: AxisMarkersSheet.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private DataElement createDefaultDataElement( )
{
	Axis axis = getAxisForProcessing( );

	if ( axis.isSetType( ) )
	{
		if ( axis.getType( ).equals( AxisType.DATE_TIME_LITERAL )
				&& !axis.isCategoryAxis( ) )
		{
			Calendar c = Calendar.getInstance( );
			c.set( 1970, 0, 1, 0, 0, 0 );
			return DateTimeDataElementImpl.create( c );
		}
		return NumberDataElementImpl.create( 0.0 );
	}
	return null;
}
 
Example 4
Source File: TemporalExpressions.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean includesDate(Calendar cal) {
    int minute = cal.get(Calendar.MINUTE);
    if (minute == this.start || minute == this.end) {
        return true;
    }
    Calendar compareCal = (Calendar) cal.clone();
    compareCal.set(Calendar.MINUTE, this.start);
    while (compareCal.get(Calendar.MINUTE) != this.end) {
        if (compareCal.get(Calendar.MINUTE) == minute) {
            return true;
        }
        compareCal.add(Calendar.MINUTE, 1);
    }
    return false;
}
 
Example 5
Source File: FormatterImpl.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
public String formatDateTimeWithFormat(final DateTime sdt, final String format) {
	Calendar cal = sdt.toJavaCal();
	if (sdt.isAnyDate() || sdt.isAnyTime()) {
		Calendar calCopy = (Calendar) cal.clone();
		if (sdt.isAnyDate()) {
			calCopy.set(YEAR, 1970);
			calCopy.set(MONTH, 0);
			calCopy.set(DAY_OF_MONTH, 1);
		}
		if (sdt.isAnyTime()) {
			calCopy.set(HOUR_OF_DAY, 0);
			calCopy.set(MINUTE, 0);
			calCopy.set(SECOND, 0);
		}
		cal = calCopy;
	}
	return formatCalWithFormat(cal, format);
}
 
Example 6
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private static Date getDate( int year, int month, int day, int hours,
		int minutes, int seconds )
{
	Date newDate = new Date( );
	Calendar calendar = getCalendar( newDate );
	calendar.set( year, month, day, hours, minutes, seconds );
	calendar.set( Calendar.MILLISECOND, 0 );
	return calendar.getTime( );
}
 
Example 7
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static Date getEarliestDate() {
    Calendar cal = getCalendarInstance(TimeZone.getTimeZone("GMT"), Locale.getDefault());
    cal.set(Calendar.YEAR, cal.getActualMinimum(Calendar.YEAR));
    cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
    cal.set(Calendar.DAY_OF_MONTH, 1);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTime();
}
 
Example 8
Source File: MonthDateFormatTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void testFormat( )
{
	Calendar calendar = Calendar.getInstance( );
	calendar.set( Calendar.YEAR, 2013 );
	calendar.set( Calendar.MONTH, 5 );
	calendar.set( Calendar.DATE, 8 );
	Date date = calendar.getTime( );
	Hashtable<ULocale, String> locales = new Hashtable<ULocale, String>( );
	locales.put( ULocale.CANADA, "Jun 2013" ); //$NON-NLS-1$
	locales.put( ULocale.CHINA, "2013年6月" ); //$NON-NLS-1$
	locales.put( ULocale.ENGLISH, "Jun 2013" ); //$NON-NLS-1$
	locales.put( ULocale.FRANCE, "juin 2013" ); //$NON-NLS-1$
	locales.put( ULocale.GERMAN, "06.2013" ); //$NON-NLS-1$
	locales.put( ULocale.ITALY, "giu 2013" ); //$NON-NLS-1$
	locales.put( ULocale.JAPAN, "2013/06" ); //$NON-NLS-1$
	locales.put( ULocale.KOREA, "2013. 6" ); //$NON-NLS-1$
	locales.put( ULocale.SIMPLIFIED_CHINESE, "2013年6月" ); //$NON-NLS-1$
	locales.put( ULocale.TAIWAN, "2013年6月" ); //$NON-NLS-1$
	locales.put( ULocale.TRADITIONAL_CHINESE, "2013年6月" ); //$NON-NLS-1$
	locales.put( ULocale.UK, "Jun 2013" ); //$NON-NLS-1$

	for ( Iterator<ULocale> itr = locales.keySet( ).iterator( ); itr.hasNext( ); )
	{
		ULocale locale = itr.next( );
		IDateFormatWrapper formatter = DateFormatWrapperFactory.getPreferredDateFormat( Calendar.MONTH,
				locale,
				true );
		assertEquals( locales.get( locale ), formatter.format( date ) );
	}
}
 
Example 9
Source File: DataTypeUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
   * 
   * @param date
   * @return
   */
  private static java.sql.Date toSqlDate( Date date )
  {
  	Calendar calendar = Calendar.getInstance( );
calendar.clear( );
calendar.setTimeInMillis( date.getTime( ) );
calendar.set( Calendar.HOUR_OF_DAY, 0 );
calendar.set( Calendar.MINUTE, 0 );
calendar.set( Calendar.SECOND, 0 );
calendar.set( Calendar.MILLISECOND, 0 );		
return new java.sql.Date( calendar.getTimeInMillis( ) );
  }
 
Example 10
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static Timestamp getDayStart(Timestamp stamp, int daysLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
Example 11
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static Timestamp getHourEnd(Timestamp stamp, Long hoursLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), tempCal.get(Calendar.HOUR_OF_DAY), 59, 59);
    tempCal.add(Calendar.HOUR_OF_DAY, hoursLater.intValue());
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
Example 12
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
/**
 * Makes a Date from separate ints for month, day, year, hour, minute, and second.
 *
 * @param month  The month int
 * @param day    The day int
 * @param year   The year int
 * @param hour   The hour int
 * @param minute The minute int
 * @param second The second int
 * @return A Date made from separate ints for month, day, year, hour, minute, and second.
 */
public static java.util.Date toDate(int month, int day, int year, int hour, int minute, int second) {
    Calendar calendar = Calendar.getInstance();

    try {
        calendar.set(year, month - 1, day, hour, minute, second);
        calendar.set(Calendar.MILLISECOND, 0);
    } catch (Exception e) {
        return null;
    }
    return new java.util.Date(calendar.getTime().getTime());
}
 
Example 13
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Object getValue( Object[] args ) throws BirtException
{
	if( existNullValue( args ) )
	{
		return null;
	}
	Date date = DataTypeUtil.toDate(args[0]);
	Calendar cal = getCalendar( date );
	int quarter = quarter( date );

	cal.set( Calendar.MONTH, ( quarter - 1 ) * 3 );
	cal.set( Calendar.DAY_OF_MONTH, 1 );
	return cal.getTime( );
}
 
Example 14
Source File: DateGroupCalculator.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public DateGroupCalculator( Object intervalStart, double intervalRange, ULocale locale, TimeZone timeZone ) throws BirtException
{
	super( intervalStart, intervalRange );
	ULocale aLocale = locale == null ? ULocale.getDefault( ):locale;
	TimeZone aZone = timeZone == null? TimeZone.getDefault( ):timeZone;
	
	Calendar c = Calendar.getInstance( aLocale );
	c.setTimeZone( aZone );
	c.clear( );
	c.set( 1970, 0, 1 );
	this.defaultStart = c.getTime( );
	this.dateTimeUtil = new DateTimeUtil( aLocale, aZone );
}
 
Example 15
Source File: AggregationTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Test
   public void test1( ) throws Exception
{
	QueryDefinition query = newReportQuery( );
	
	Calendar c = Calendar.getInstance( );
	c.clear( );
	// 3 grouping levels: CITY, STORE, SALE_DATE(by month)
	GroupDefinition g1 = new GroupDefinition( "G1" );
	g1.setKeyExpression( "row.e1" );
	query.addGroup( g1 );

	GroupDefinition g2 = new GroupDefinition( "G2" );
	g2.setKeyExpression( "row.e2" );
	
	query.addGroup( g2 );

	GroupDefinition g3 = new GroupDefinition( "G3" );
	g3.setKeyExpression( "row.e3" );
	g3.setInterval( GroupDefinition.MONTH_INTERVAL );
	g3.setIntervalRange( 1 );
	
	c.set( 2004, 9, 1 );
	g3.setIntervalStart( c.getTime( ) );
	query.addGroup( g3 );
	
	SortDefinition sort = new SortDefinition( );
	sort.setExpression( "row.e3" );
	sort.setSortDirection( ISortDefinition.SORT_ASC );
	query.addSort( sort );
	
	query.addBinding( new Binding( "e1", new ScriptExpression( "dataSetRow.CITY" ) ) );
	query.addBinding( new Binding( "e2", new ScriptExpression( "dataSetRow.STORE" ) ) );
	query.addBinding( new Binding( "e3", new ScriptExpression( "dataSetRow.SALE_DATE" ) ) );
	query.addBinding( new Binding( "e4", new ScriptExpression( "dataSetRow.SKU" ) ) );
	query.addBinding( new Binding( "e10", new ScriptExpression( "dataSetRow.PRICE" ) ) );
	query.addBinding( new Binding( "e11", new ScriptExpression( "dataSetRow.QUANTITY" ) ) );
	
	// Aggregate: count at city level
	IBinding e5 = new Binding( "e5" );
	e5.setAggrFunction( "COUNT" );
	e5.addAggregateOn( "G1" );
	query.addBinding( e5 );

	// Aggregate: count at city level but added to Store group
	IBinding e6 = new Binding( "e6");
	e6.setAggrFunction( "COUNT" );
	e6.addAggregateOn( "G1" );
	query.addBinding( e6 );

	// Aggregate: day total sales
	IBinding e7 = new Binding( "e7", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e7.setAggrFunction( "SUM" );
	e7.addAggregateOn( "G3" );
	query.addBinding( e7 );
	
	IBinding e81 = new Binding( "e81", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e81.setAggrFunction( "SUM" );
	query.addBinding( e81 );
	
	// Aggregate: Percent of grand total
	IBinding e8 = new Binding( "e8", new ScriptExpression( "dataSetRow.PRICE * dataSetRow.QUANTITY / row.e81" ));
	query.addBinding( e8 );

	// Aggregate: a moving ave with a filtering condition
	IBinding e9 = new Binding( "e9", new ScriptExpression( "dataSetRow.PRICE"));
	e9.setAggrFunction( "MOVINGAVE" );
	e9.setFilter( new ScriptExpression ("dataSetRow.QUANTITY>1")  );
	e9.addArgument( new ScriptExpression( "3") );
	query.addBinding( e9 );
	String[] exprs = new String[]{
			"e1", "e2", "e3", "e4", "e10", "e11", "e5", "e6", "e7", "e8", "e9"
	};

	outputQueryResult( executeQuery( query ), exprs );
	checkOutputFile();
}
 
Example 16
Source File: AggregationTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Test
   public void test8( ) throws Exception
{
	QueryDefinition query = newReportQuery( );
	
	Calendar c = Calendar.getInstance( );
	c.clear( );
	// 3 grouping levels: CITY, STORE, SALE_DATE(by month)
	GroupDefinition g1 = new GroupDefinition( "G1" );
	g1.setKeyExpression( "row.e1" );
	query.addGroup( g1 );

	GroupDefinition g2 = new GroupDefinition( "G2" );
	g2.setKeyExpression( "row.e2" );
	
	query.addGroup( g2 );

	GroupDefinition g3 = new GroupDefinition( "G3" );
	g3.setKeyExpression( "row.e3" );
	g3.setInterval( GroupDefinition.MONTH_INTERVAL );
	g3.setIntervalRange( 1 );
	
	c.set( 2004, 9, 1 );
	g3.setIntervalStart( c.getTime( ) );
	query.addGroup( g3 );
	
	SortDefinition sort = new SortDefinition( );
	sort.setExpression( "row.e3" );
	sort.setSortDirection( ISortDefinition.SORT_ASC );
	query.addSort( sort );
	
	query.addBinding( new Binding( "e1", new ScriptExpression( "dataSetRow.CITY" ) ) );
	query.addBinding( new Binding( "e2", new ScriptExpression( "dataSetRow.STORE" ) ) );
	query.addBinding( new Binding( "e3", new ScriptExpression( "dataSetRow.SALE_DATE" ) ) );
	query.addBinding( new Binding( "e4", new ScriptExpression( "dataSetRow.SKU" ) ) );
	query.addBinding( new Binding( "e10", new ScriptExpression( "dataSetRow.PRICE" ) ) );
	query.addBinding( new Binding( "e11", new ScriptExpression( "dataSetRow.QUANTITY" ) ) );
	
	// Aggregate: count at city level
	IBinding e5 = new Binding( "e5" );
	e5.setAggrFunction( "COUNT" );
	e5.addAggregateOn( "G1" );
	query.addBinding( e5 );

	// Aggregate: count at city level but added to Store group
	IBinding e6 = new Binding( "e6");
	e6.setAggrFunction( "COUNT" );
	e6.addAggregateOn( "G1" );
	query.addBinding( e6 );

	// Aggregate: day total sales
	IBinding e7 = new Binding( "e7", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e7.setAggrFunction( "SUM" );
	e7.addAggregateOn( "G3" );
	query.addBinding( e7 );
	
	IBinding e81 = new Binding( "e81", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e81.setAggrFunction( "SUM" );
	query.addBinding( e81 );
	
	// Aggregate: Percent of grand total
	IBinding e8 = new Binding( "e8", new ScriptExpression( "row.e7 / row.e81" ));
	query.addBinding( e8 );

	// Aggregate: day total sales
			IBinding e9 = new Binding( "e9", new ScriptExpression("row.e8"));
			e9.setAggrFunction( "SUM" );
			query.addBinding( e9 );
	
	String[] exprs = new String[]{
			"e1", "e2", "e3", "e4", "e10", "e11", "e5", "e6", "e7", "e8", "e9"
	};

	outputQueryResult( executeQuery( query ), exprs );
	checkOutputFile();
}
 
Example 17
Source File: Session.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
@Override
public DateTime createDateTime(final int y, final int m, final int d, final int h, final int i, final int s) {
	Calendar cal = Calendar.getInstance();
	cal.set(y, m - 1, d, h, i, s);
	return createDateTime(cal);
}
 
Example 18
Source File: AggregationTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Test
   public void test11( ) throws Exception
{
	QueryDefinition query = newReportQuery( );
	
	Calendar c = Calendar.getInstance( );
	c.clear( );
	// 3 grouping levels: CITY, STORE, SALE_DATE(by month)
	GroupDefinition g1 = new GroupDefinition( "G1" );
	g1.setKeyExpression( "row.e1" );
	
	SortDefinition sortDefn = new SortDefinition();
	sortDefn.setExpression( "row.e5" );
	sortDefn.setSortDirection( ISortDefinition.SORT_DESC );
	g1.addSort( sortDefn );
	FilterDefinition filter = new FilterDefinition( new ScriptExpression( "row.e7 > 100" ) );
	g1.addFilter( filter );
	
	query.addGroup( g1 );

	GroupDefinition g2 = new GroupDefinition( "G2" );
	g2.setKeyExpression( "row.e2" );
	
	query.addGroup( g2 );

	GroupDefinition g3 = new GroupDefinition( "G3" );
	g3.setKeyExpression( "row.e3" );
	g3.setInterval( GroupDefinition.MONTH_INTERVAL );
	g3.setIntervalRange( 1 );
	
	c.set( 2004, 9, 1 );
	g3.setIntervalStart( c.getTime( ) );
	query.addGroup( g3 );
	
	SortDefinition sort = new SortDefinition( );
	sort.setExpression( "row.e3" );
	sort.setSortDirection( ISortDefinition.SORT_ASC );
	query.addSort( sort );
	
	query.addBinding( new Binding( "e1", new ScriptExpression( "dataSetRow.CITY" ) ) );
	query.addBinding( new Binding( "e2", new ScriptExpression( "dataSetRow.STORE" ) ) );
	query.addBinding( new Binding( "e3", new ScriptExpression( "dataSetRow.SALE_DATE" ) ) );
	query.addBinding( new Binding( "e4", new ScriptExpression( "dataSetRow.SKU" ) ) );
	query.addBinding( new Binding( "e10", new ScriptExpression( "dataSetRow.PRICE" ) ) );
	query.addBinding( new Binding( "e11", new ScriptExpression( "dataSetRow.QUANTITY" ) ) );
	
	// Aggregate: count at city level
	IBinding e5 = new Binding( "e5" );
	e5.setAggrFunction( "COUNT" );
	e5.addAggregateOn( "G1" );
	query.addBinding( e5 );

	// Aggregate: count at city level but added to Store group
	IBinding e6 = new Binding( "e6");
	e6.setAggrFunction( "COUNT" );
	e6.addAggregateOn( "G1" );
	query.addBinding( e6 );

	// Aggregate: day total sales
	IBinding e7 = new Binding( "e7", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e7.setAggrFunction( "SUM" );
	e7.addAggregateOn( "G3" );
	query.addBinding( e7 );
	
	IBinding e81 = new Binding( "e81", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e81.setAggrFunction( "SUM" );
	query.addBinding( e81 );
	
	// Aggregate: Percent of grand total
	IBinding e8 = new Binding( "e8", new ScriptExpression( "dataSetRow.PRICE * dataSetRow.QUANTITY / row.e81" ));
	query.addBinding( e8 );

	// Aggregate: a moving ave with a filtering condition
	IBinding e9 = new Binding( "e9", new ScriptExpression( "dataSetRow.PRICE"));
	e9.setAggrFunction( "MOVINGAVE" );
	e9.setFilter( new ScriptExpression ("dataSetRow.QUANTITY>1")  );
	e9.addArgument( new ScriptExpression( "3") );
	query.addBinding( e9 );
	String[] exprs = new String[]{
			"e1", "e2", "e3", "e4", "e10", "e11", "e5", "e6", "e7", "e8", "e9"
	};

	outputQueryResult( executeQuery( query ), exprs );
	checkOutputFile();
}
 
Example 19
Source File: TrailingFunction.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void setToWeekEnd( Calendar cal)
{
	cal.set( Calendar.DAY_OF_WEEK, 7 );
}
 
Example 20
Source File: AggregationTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Test
   public void test2( ) throws Exception
{
	QueryDefinition query = newReportQuery( );
	
	Calendar c = Calendar.getInstance( );
	c.clear( );
	// 3 grouping levels: CITY, STORE, SALE_DATE(by month)
	GroupDefinition g1 = new GroupDefinition( "G1" );
	g1.setKeyExpression( "row.e1" );
	query.addGroup( g1 );

	GroupDefinition g2 = new GroupDefinition( "G2" );
	g2.setKeyExpression( "row.e2" );
	
	query.addGroup( g2 );

	GroupDefinition g3 = new GroupDefinition( "G3" );
	g3.setKeyExpression( "row.e3" );
	g3.setInterval( GroupDefinition.MONTH_INTERVAL );
	g3.setIntervalRange( 1 );
	
	c.set( 2004, 9, 1 );
	g3.setIntervalStart( c.getTime( ) );
	query.addGroup( g3 );
	
	SortDefinition sort = new SortDefinition( );
	sort.setExpression( "row.e3" );
	sort.setSortDirection( ISortDefinition.SORT_ASC );
	query.addSort( sort );
	
	query.addBinding( new Binding( "e1", new ScriptExpression( "dataSetRow.CITY" ) ) );
	query.addBinding( new Binding( "e2", new ScriptExpression( "dataSetRow.STORE" ) ) );
	query.addBinding( new Binding( "e3", new ScriptExpression( "dataSetRow.SALE_DATE" ) ) );
	query.addBinding( new Binding( "e4", new ScriptExpression( "dataSetRow.SKU" ) ) );
	query.addBinding( new Binding( "e10", new ScriptExpression( "dataSetRow.PRICE" ) ) );
	query.addBinding( new Binding( "e11", new ScriptExpression( "dataSetRow.QUANTITY" ) ) );
	
	// Aggregate: count at city level
	IBinding e5 = new Binding( "e5" );
	e5.setAggrFunction( "COUNT" );
	e5.addAggregateOn( "G1" );
	query.addBinding( e5 );

	// Aggregate: count at city level but added to Store group
	IBinding e6 = new Binding( "e6");
	e6.setAggrFunction( "COUNT" );
	e6.addAggregateOn( "G1" );
	query.addBinding( e6 );

	// Aggregate: day total sales
	IBinding e7 = new Binding( "e7", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e7.setAggrFunction( "SUM" );
	e7.addAggregateOn( "G3" );
	query.addBinding( e7 );
	
	FilterDefinition f1 = new FilterDefinition( new ConditionalExpression( "row[\"e7\"]" , IConditionalExpression.OP_TOP_N, "2" ) );
	query.addFilter( f1 );
	
	
	
	IBinding e81 = new Binding( "e81", new ScriptExpression("dataSetRow.PRICE*dataSetRow.QUANTITY"));
	e81.setAggrFunction( "SUM" );
	query.addBinding( e81 );
	
	// Aggregate: Percent of grand total
	IBinding e8 = new Binding( "e8", new ScriptExpression( "dataSetRow.PRICE * dataSetRow.QUANTITY / row.e81" ));
	query.addBinding( e8 );

	// Aggregate: a moving ave with a filtering condition
	IBinding e9 = new Binding( "e9", new ScriptExpression( "dataSetRow.PRICE"));
	e9.setAggrFunction( "MOVINGAVE" );
	e9.setFilter( new ScriptExpression ("dataSetRow.QUANTITY>1")  );
	e9.addArgument( new ScriptExpression( "3") );
	query.addBinding( e9 );
	String[] exprs = new String[]{
			"e1", "e2", "e3", "e4", "e10", "e11", "e5", "e6", "e7", "e8", "e9"
	};

	outputQueryResult( executeQuery( query ), exprs );
	checkOutputFile();
}