Java Code Examples for com.ibm.icu.util.Calendar#JANUARY
The following examples show how to use
com.ibm.icu.util.Calendar#JANUARY .
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: ICalRecurConverter.java From scipio-erp with Apache License 2.0 | 6 votes |
@Override public void visit(TemporalExpressions.MonthRange expr) { int startMonth = expr.getStartMonth(); int endMonth = expr.getEndMonth(); Calendar cal = Calendar.getInstance(); int maxMonth = cal.getActualMaximum(Calendar.MONTH); NumberList monthList = new NumberList(); monthList.add(startMonth + 1); while (startMonth != endMonth) { startMonth++; if (startMonth > maxMonth) { startMonth = Calendar.JANUARY; } monthList.add(startMonth + 1); } Recur recur = new Recur(Recur.MONTHLY, 0); recur.getMonthList().addAll(monthList); this.state.addRecur(recur); }
Example 2
Source File: TimeMemberUtil.java From birt with Eclipse Public License 1.0 | 6 votes |
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 3
Source File: OlsonTimeZone.java From fitnotifications with Apache License 2.0 | 5 votes |
@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 4
Source File: OlsonTimeZone.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: UtilDateTime.java From scipio-erp with Apache License 2.0 | 5 votes |
/** * Returns a List of month name Strings - suitable for calendar headings. * * @param locale * @return List of month name Strings */ public static List<String> getMonthNames(Locale locale) { Calendar tempCal = Calendar.getInstance(locale); tempCal.set(Calendar.MONTH, Calendar.JANUARY); SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM", locale); List<String> resultList = new ArrayList<>(); for (int i = Calendar.JANUARY; i <= tempCal.getActualMaximum(Calendar.MONTH); i++) { resultList.add(dateFormat.format(tempCal.getTime())); tempCal.roll(Calendar.MONTH, 1); } return resultList; }
Example 6
Source File: TemporalExpressions.java From scipio-erp with Apache License 2.0 | 5 votes |
/** * @param start An integer in the range of <code>Calendar.JANUARY</code> * to <code>Calendar.UNDECIMBER</code> * @param end An integer in the range of <code>Calendar.JANUARY</code> * to <code>Calendar.UNDECIMBER</code> */ public MonthRange(int start, int end) { if (start < Calendar.JANUARY || start > Calendar.UNDECIMBER) { throw new IllegalArgumentException("Invalid start argument"); } if (end < Calendar.JANUARY || end > Calendar.UNDECIMBER) { throw new IllegalArgumentException("Invalid end argument"); } this.sequence = SEQUENCE_MONTH_RANGE + start; this.start = start; this.end = end; if (Debug.verboseOn()) { Debug.logVerbose("Created " + this, module); } }
Example 7
Source File: ExpressionUiHelper.java From scipio-erp with Apache License 2.0 | 5 votes |
/** Returns a List of Maps containing month values. * @param locale * @return List of Maps. Each Map has a * <code>description</code> entry and a <code>value</code> entry. */ public static List<Map<String, Object>> getMonthValueList(Locale locale) { Calendar tempCal = Calendar.getInstance(locale); tempCal.set(Calendar.MONTH, Calendar.JANUARY); SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM", locale); List<Map<String, Object>> result = new ArrayList<>(13); for (int i = Calendar.JANUARY; i <= tempCal.getActualMaximum(Calendar.MONTH); i++) { result.add(UtilMisc.toMap("description", (Object)dateFormat.format(tempCal.getTime()), "value", i)); tempCal.roll(Calendar.MONTH, 1); } return result; }
Example 8
Source File: CDateTime.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * 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 9
Source File: BirtDateTime.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * 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 10
Source File: DateTimeUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * 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 11
Source File: DataSetIterator.java From birt with Eclipse Public License 1.0 | 4 votes |
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 12
Source File: TimeDimensionDatasetIterator.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * * @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 ); }