Java Code Examples for com.ibm.icu.util.Calendar#DECEMBER

The following examples show how to use com.ibm.icu.util.Calendar#DECEMBER . 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: TimeMemberUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private static int quarter( Calendar cal )
{
	int month = cal.get( Calendar.MONTH );
	switch ( month )
	{
		case Calendar.JANUARY :
		case Calendar.FEBRUARY :
		case Calendar.MARCH :
			return 1;
		case Calendar.APRIL :
		case Calendar.MAY :
		case Calendar.JUNE :
			return 2;
		case Calendar.JULY :
		case Calendar.AUGUST :
		case Calendar.SEPTEMBER :
			return 3;
		case Calendar.OCTOBER :
		case Calendar.NOVEMBER :
		case Calendar.DECEMBER :
			return 4;
		default :
			return -1;
	}
}
 
Example 2
Source File: OlsonTimeZone.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
@Override
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) {
    if (month < Calendar.JANUARY || month > Calendar.DECEMBER) {
        throw new IllegalArgumentException("Month is not in the legal range: " +month);
    } else {
        return getOffset(era, year, month, day, dayOfWeek, milliseconds, Grego.monthLength(year, month));
    }
}
 
Example 3
Source File: OlsonTimeZone.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * TimeZone API.
 */
public int getOffset(int era, int year, int month,int dom, int dow, int millis, int monthLength){

    if ((era != GregorianCalendar.AD && era != GregorianCalendar.BC)
        || month < Calendar.JANUARY
        || month > Calendar.DECEMBER
        || dom < 1
        || dom > monthLength
        || dow < Calendar.SUNDAY
        || dow > Calendar.SATURDAY
        || millis < 0
        || millis >= Grego.MILLIS_PER_DAY
        || monthLength < 28
        || monthLength > 31) {
        throw new IllegalArgumentException();
    }

    if (era == GregorianCalendar.BC) {
        year = -year;
    }

    if (finalZone != null && year >= finalStartYear) {
        return finalZone.getOffset(era, year, month, dom, dow, millis);
    }

    // Compute local epoch millis from input fields
    long time = Grego.fieldsToDay(year, month, dom) * Grego.MILLIS_PER_DAY + millis;

    int[] offsets = new int[2];
    getHistoricalOffset(time, true, LOCAL_DST, LOCAL_STD, offsets);
    return offsets[0] + offsets[1];
}
 
Example 4
Source File: CDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Quarter number (1 to 4) of date/time value d The method is merged from
 * DtE's API.
 * 
 * @param d
 * @return
 * @since 2.3
 */
private static int numberOfQuarter( CDateTime d )
{
	if ( d == null )
		throw new java.lang.IllegalArgumentException( "date value is null!" ); //$NON-NLS-1$

	int month = d.getMonth( );
	switch ( month )
	{
		case Calendar.JANUARY :
		case Calendar.FEBRUARY :
		case Calendar.MARCH :
			return 1;
		case Calendar.APRIL :
		case Calendar.MAY :
		case Calendar.JUNE :
			return 2;
		case Calendar.JULY :
		case Calendar.AUGUST :
		case Calendar.SEPTEMBER :
			return 3;
		case Calendar.OCTOBER :
		case Calendar.NOVEMBER :
		case Calendar.DECEMBER :
			return 4;
		default :
			return -1;
	}
}
 
Example 5
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Quarter number (1 to 4) of date/time value d
 *
 * @param d
 * @return
 */
private static int quarter( Date d )
{
	if ( d == null )
		throw new java.lang.IllegalArgumentException( Messages.getString( "error.BirtDateTime.cannotBeNull.DateValue" ) );

	int month = getCalendar( d ).get( Calendar.MONTH );
	switch ( month )
	{
		case Calendar.JANUARY :
		case Calendar.FEBRUARY :
		case Calendar.MARCH :
			return 1;
		case Calendar.APRIL :
		case Calendar.MAY :
		case Calendar.JUNE :
			return 2;
		case Calendar.JULY :
		case Calendar.AUGUST :
		case Calendar.SEPTEMBER :
			return 3;
		case Calendar.OCTOBER :
		case Calendar.NOVEMBER :
		case Calendar.DECEMBER :
			return 4;
		default :
			return -1;
	}
}
 
Example 6
Source File: DateTimeUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Quarter number (1 to 4) of date/time value d
 * 
 * @param d
 * @return
 */
public int quarter( Date d )
{
	if ( d == null )
		throw new java.lang.IllegalArgumentException( "date value is null!" );

	int month = getCalendar( d ).get( Calendar.MONTH );
	switch ( month )
	{
		case Calendar.JANUARY :
		case Calendar.FEBRUARY :
		case Calendar.MARCH :
			return 1;
		case Calendar.APRIL :
		case Calendar.MAY :
		case Calendar.JUNE :
			return 2;
		case Calendar.JULY :
		case Calendar.AUGUST :
		case Calendar.SEPTEMBER :
			return 3;
		case Calendar.OCTOBER :
		case Calendar.NOVEMBER :
		case Calendar.DECEMBER :
			return 4;
		default :
			return -1;
	}
}
 
Example 7
Source File: DataSetIterator.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Object process( Object d ) throws AdapterException
{
	if( d == null )
		return null;
	
	populateCalendar( d );
	if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_MONTH.equals( timeType ) 
		 || DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_WEEK.equals( timeType )
		 || DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR.equals( timeType )
		 || DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_MONTH.equals( timeType )
		 || DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_YEAR.equals( timeType ))
	{
		cleanTimePortion( this.calendar );
		return this.calendar.getTime();
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_MONTH.equals( timeType ) )
	{
		//For all month, clear time portion and set DayOfMonth to 1.
		cleanTimePortion( this.calendar );
		this.calendar.set( Calendar.DATE, 1 );
		return this.calendar.getTime();
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_QUARTER.equals( timeType ) )
	{
		//For all quarter, clear time portion and set month to first month of 
		//that quarter and set day to first day of that month.
		cleanTimePortion( this.calendar );
		this.calendar.set( Calendar.DATE, 1 );
		int month = this.calendar.get( Calendar.MONTH );
		switch ( month )
		{
			case Calendar.JANUARY :
			case Calendar.FEBRUARY :
			case Calendar.MARCH :
				this.calendar.set(Calendar.MONTH, 0);
				break;
			case Calendar.APRIL :
			case Calendar.MAY :
			case Calendar.JUNE :
				this.calendar.set(Calendar.MONTH, 3);
				break;
			case Calendar.JULY :
			case Calendar.AUGUST :
			case Calendar.SEPTEMBER :
				this.calendar.set(Calendar.MONTH, 6);
				break;
			case Calendar.OCTOBER :
			case Calendar.NOVEMBER :
			case Calendar.DECEMBER :
				this.calendar.set(Calendar.MONTH, 9);
				break;
		}
		return this.calendar.getTime();
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_YEAR.equals( timeType ) )
	{
		//For year, clear all time portion and set Date to Jan 1st.
		cleanTimePortion( this.calendar );
		this.calendar.set(Calendar.MONTH, 0);
		this.calendar.set(Calendar.DATE, 1);
		return this.calendar.getTime();
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_HOUR.equals( timeType ) )
	{
		//For hour, set minute to 0 and second to 1.
		this.calendar.set(Calendar.MINUTE, 0);
		this.calendar.set(Calendar.SECOND, 1);
		this.calendar.set(Calendar.MILLISECOND, 0);
		return this.calendar.getTime();
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_MINUTE.equals( timeType ) )
	{
		//For minute, set second to 1.
		this.calendar.set(Calendar.SECOND, 1);
		this.calendar.set(Calendar.MILLISECOND, 0);
		return this.calendar.getTime();
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_SECOND.equals( timeType ) )
	{
		//For second, set millisecond to 0.
		this.calendar.set(Calendar.MILLISECOND, 0);
		return this.calendar.getTime();
	}
	else
		throw new AdapterException( ResourceConstants.INVALID_DATE_TIME_TYPE, timeType );
	
}
 
Example 8
Source File: TimeDimensionDatasetIterator.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 
 * @param timeType
 * @param d
 * @return
 * @throws BirtException
 */
protected Object getValue( String timeType, Object d ) throws BirtException
{
	if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_MONTH.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.DAY_OF_MONTH ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_WEEK.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.DAY_OF_WEEK ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.DAY_OF_YEAR ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_MONTH.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.WEEK_OF_MONTH ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_YEAR.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.WEEK_OF_YEAR ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_MONTH.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.MONTH ) + 1 );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_QUARTER.equals( timeType ) )
	{
		int month = getCalendar( d ).get( Calendar.MONTH );
		int quarter = -1;
		switch ( month )
		{
			case Calendar.JANUARY :
			case Calendar.FEBRUARY :
			case Calendar.MARCH :
				quarter = 1;
				break;
			case Calendar.APRIL :
			case Calendar.MAY :
			case Calendar.JUNE :
				quarter = 2;
				break;
			case Calendar.JULY :
			case Calendar.AUGUST :
			case Calendar.SEPTEMBER :
				quarter = 3;
				break;
			case Calendar.OCTOBER :
			case Calendar.NOVEMBER :
			case Calendar.DECEMBER :
				quarter = 4;
				break;
			default :
				quarter = -1;
		}
		return new Integer( quarter );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_YEAR.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.YEAR ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_HOUR.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.HOUR_OF_DAY ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_MINUTE.equals( timeType ) )
	{
		return new Integer( getCalendar( d ).get( Calendar.MINUTE ) );
	}
	else if ( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_SECOND.equals( timeType ) )
	{
		return Integer.valueOf( getCalendar( d ).get( Calendar.SECOND ) );
	}
	else
		throw new AdapterException( ResourceConstants.INVALID_DATE_TIME_TYPE, timeType );
}