Java Code Examples for com.ibm.icu.util.Calendar#getActualMaximum()
The following examples show how to use
com.ibm.icu.util.Calendar#getActualMaximum() .
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: BirtDateTime.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * * @param d1 * @param d2 * @return */ static private long diffDay( Calendar d1, Calendar d2 ) { int days = d2.get( Calendar.DAY_OF_YEAR ) - d1.get( Calendar.DAY_OF_YEAR ); int y2 = d2.get( Calendar.YEAR ); if ( d1.get( Calendar.YEAR ) != y2 ) { do { days += d1.getActualMaximum( Calendar.DAY_OF_YEAR ); d1.add( Calendar.YEAR, 1 ); } while ( d1.get( Calendar.YEAR ) != y2 ); } return days; }
Example 3
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 4
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 5
Source File: SpinnerTable.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * sets the calendar * * @param calendar */ public void setCalendar( Calendar calendar ) { this.cale = (Calendar) calendar.clone( ); Calendar tempcalendar = getOriCalendar( calendar ); int dayCount = tempcalendar.getActualMaximum( Calendar.DAY_OF_MONTH ); int moreDayCount = tempcalendar.get( Calendar.DAY_OF_WEEK ) - 1; //int count = table.getItemCount(); for ( int i = 0; i < ROW_COUNT; i++ ) { TableItem item = table.getItem( i ); if ( i == 0 ) { continue; } String[] values = new String[7]; for ( int j = 0; j < DAY_WEEK_COUNT; j++ ) { int index = ( i - 1 ) * DAY_WEEK_COUNT + j; int dayIndex = index - moreDayCount + 1; if ( index < moreDayCount || dayIndex > dayCount ) { values[j] = ""; //$NON-NLS-1$ } else { values[j] = String.valueOf( dayIndex ); } } item.setText( values ); } TableColumn[] cols = table.getColumns( ); int size = cols.length; for ( int i = 0; i < size; i++ ) { cols[i].pack( ); } table.pack( ); setOriValue( ); }