當前位置: 首頁>>代碼示例>>Java>>正文


Java Calendar.MONTH屬性代碼示例

本文整理匯總了Java中java.util.Calendar.MONTH屬性的典型用法代碼示例。如果您正苦於以下問題:Java Calendar.MONTH屬性的具體用法?Java Calendar.MONTH怎麽用?Java Calendar.MONTH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.util.Calendar的用法示例。


在下文中一共展示了Calendar.MONTH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: translate

private static int translate(final IntervalUnit unit) {
	switch (unit) {
	case DAY:
		return Calendar.DAY_OF_YEAR;
	case HOUR:
		return Calendar.HOUR_OF_DAY;
	case MINUTE:
		return Calendar.MINUTE;
	case MONTH:
		return Calendar.MONTH;
	case SECOND:
		return Calendar.SECOND;
	case MILLISECOND:
		return Calendar.MILLISECOND;
	case WEEK:
		return Calendar.WEEK_OF_YEAR;
	case YEAR:
		return Calendar.YEAR;
	default:
		throw new IllegalArgumentException("Unknown IntervalUnit");
	}
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:22,代碼來源:DateUtil.java

示例2: getDateEnd

/**
 * @param dateAndResolution
 * @return String date
 */
public static String getDateEnd(Pair<Date, Integer> dateAndResolution)
{
    Calendar cal = Calendar.getInstance(I18NUtil.getLocale());
    cal.setTime(dateAndResolution.getFirst());
    switch (dateAndResolution.getSecond())
    {
        case Calendar.YEAR:
            cal.set(Calendar.MONTH, cal.getActualMaximum(Calendar.MONTH));
        case Calendar.MONTH:
            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
        case Calendar.DAY_OF_MONTH:
            cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY));
        case Calendar.HOUR_OF_DAY:
            cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE));
        case Calendar.MINUTE:
            cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND));
        case Calendar.SECOND:
            cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND));
        case Calendar.MILLISECOND:
        default:
    }
    SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat();
    formatter.setTimeZone(UTC_TIMEZONE);
    return formatter.format(cal.getTime());
}
 
開發者ID:Alfresco,項目名稱:alfresco-data-model,代碼行數:29,代碼來源:SearchDateConversion.java

示例3: makeCalendar

private Calendar makeCalendar ( final int[] is, final String[] strings )
{
    final Calendar c = Calendar.getInstance ();

    if ( is.length != strings.length )
    {
        throw new IllegalArgumentException ( "Array length is not equal. Internal error." );
    }

    for ( int i = 0; i < is.length; i++ )
    {
        if ( is[i] == Calendar.MONTH )
        {
            c.set ( is[i], Integer.parseInt ( strings[i] ) - 1 );
        }
        else
        {
            c.set ( is[i], Integer.parseInt ( strings[i] ) );
        }
    }
    return c;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:DateTimeDialog.java

示例4: getCalendarFieldForPeriod

/**
 * Determines the calendar field object that corresponds to the given
 * period.
 * 
 * @param period
 *            The specifie period.
 * @return The calendar field.
 */
private int getCalendarFieldForPeriod(Period period) {
    int field;
    switch (period) {
    case MONTH:
        field = Calendar.MONTH;
        break;
    case DAY:
        field = Calendar.DAY_OF_YEAR;
        break;
    default:
        // init the default period to day of year.
        field = Calendar.DAY_OF_YEAR;
    }
    return field;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:23,代碼來源:TimerServiceBean.java

示例5: previous

/**
 * Operation is based on java util calendar in order to support daylight
 * saving times.
 */
public TimeSlice previous() {
    long newStart = start;
    long newEnd = end;
    Calendar temp = Calendar.getInstance();
    temp.setTimeInMillis(start);
    int field = 0;
    switch (period) {
    case HOUR:
        field = Calendar.HOUR_OF_DAY;
        break;
    case DAY:
        field = Calendar.DAY_OF_MONTH;
        break;
    case WEEK:
        field = Calendar.WEEK_OF_YEAR;
        break;
    case MONTH:
        field = Calendar.MONTH;
        break;
    default:
        break;
    }
    temp.add(field, -1);
    newStart = temp.getTimeInMillis();
    temp.setTimeInMillis(end);
    temp.add(field, -1);
    newEnd = temp.getTimeInMillis();
    return new TimeSlice(newStart, newEnd, period);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:33,代碼來源:TimeSlice.java

示例6: getCalendarField

/**
 * Returns a field code (that can be used with the Calendar class) for a given 'unit' code.
 * The 'unit' is one of:  YEAR, MONTH, DAY, HOUR, MINUTE, SECOND and MILLISECOND.
 *
 * @param unit  the unit.
 *
 * @return the field code.
 */
private int getCalendarField(int unit) {

    switch (unit) {
        case (YEAR):
            return Calendar.YEAR;
        case (MONTH):
            return Calendar.MONTH;
        case (DAY):
            return Calendar.DATE;
        case (HOUR):
            return Calendar.HOUR_OF_DAY;
        case (MINUTE):
            return Calendar.MINUTE;
        case (SECOND):
            return Calendar.SECOND;
        case (MILLISECOND):
            return Calendar.MILLISECOND;
        default:
            return Calendar.MILLISECOND;
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:DateTickUnit.java

示例7: getCalendarField

/**
 * Returns a field code (that can be used with the Calendar class) for a 
 * given 'unit' code.  The 'unit' is one of:  {@link #YEAR}, {@link #MONTH},
 * {@link #DAY}, {@link #HOUR}, {@link #MINUTE}, {@link #SECOND} and 
 * {@link #MILLISECOND}.
 *
 * @param tickUnit  the unit.
 *
 * @return The field code.
 */
private int getCalendarField(int tickUnit) {

    switch (tickUnit) {
        case (YEAR):
            return Calendar.YEAR;
        case (MONTH):
            return Calendar.MONTH;
        case (DAY):
            return Calendar.DATE;
        case (HOUR):
            return Calendar.HOUR_OF_DAY;
        case (MINUTE):
            return Calendar.MINUTE;
        case (SECOND):
            return Calendar.SECOND;
        case (MILLISECOND):
            return Calendar.MILLISECOND;
        default:
            return Calendar.MILLISECOND;
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:DateTickUnit.java

示例8: getTimeRelativeTo

public long getTimeRelativeTo(long time)
{
	int valueToUse = -(int) value;
	int field = 0;
	if (getUnit() == TimeUnit.MILLISECONDS)
	{
		field = Calendar.MILLISECOND;
		//we do our own adjustment as calendar cannot handle a long.
		time -= value;
		valueToUse = 0;
	}
	else if (getUnit() == TimeUnit.SECONDS)
		field = Calendar.SECOND;
	else if (getUnit() == TimeUnit.MINUTES)
		field = Calendar.MINUTE;
	else if (getUnit() == TimeUnit.HOURS)
		field = Calendar.HOUR;
	else if (getUnit() == TimeUnit.DAYS)
		field = Calendar.DATE;
	else if (getUnit() == TimeUnit.WEEKS)
		field = Calendar.WEEK_OF_MONTH;
	else if (getUnit() == TimeUnit.MONTHS)
		field = Calendar.MONTH;
	else if (getUnit() == TimeUnit.YEARS)
		field = Calendar.YEAR;

	calendar.setTimeInMillis(time);
	calendar.add(field, valueToUse);

	return calendar.getTime().getTime();
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:31,代碼來源:RelativeTime.java

示例9: getFutureTimeRelativeTo

public long getFutureTimeRelativeTo(long time)
{
	int valueToUse = (int) value;
	int field = 0;
	if (getUnit() == TimeUnit.MILLISECONDS)
	{
		field = Calendar.MILLISECOND;
		//we do our own adjustment as calendar cannot handle a long.
		time += value;
		valueToUse = 0;
	}
	else if (getUnit() == TimeUnit.SECONDS)
		field = Calendar.SECOND;
	else if (getUnit() == TimeUnit.MINUTES)
		field = Calendar.MINUTE;
	else if (getUnit() == TimeUnit.HOURS)
		field = Calendar.HOUR;
	else if (getUnit() == TimeUnit.DAYS)
		field = Calendar.DATE;
	else if (getUnit() == TimeUnit.WEEKS)
		field = Calendar.WEEK_OF_MONTH;
	else if (getUnit() == TimeUnit.MONTHS)
		field = Calendar.MONTH;
	else if (getUnit() == TimeUnit.YEARS)
		field = Calendar.YEAR;

	calendar.setTimeInMillis(time);
	calendar.add(field, valueToUse);

	return calendar.getTime().getTime();
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:31,代碼來源:RelativeTime.java

示例10: Adjustment

public Adjustment(int field, int amount) {
	this.originalField = field;

	switch (field) {
		case CALENDAR_FIELD_YEAR:
			this.calendarField = Calendar.YEAR;
			break;
		case CALENDAR_FIELD_MONTH:
			this.calendarField = Calendar.MONTH;
			break;
		case CALENDAR_FIELD_DAY:
			this.calendarField = Calendar.DAY_OF_YEAR;
			break;
		case CALENDAR_FIELD_HOUR:
			this.calendarField = Calendar.HOUR_OF_DAY;
			break;
		case CALENDAR_FIELD_MINUTE:
			this.calendarField = Calendar.MINUTE;
			break;
		case CALENDAR_FIELD_SECOND:
			this.calendarField = Calendar.SECOND;
			break;
		case CALENDAR_FIELD_MILLISECOND:
			this.calendarField = Calendar.MILLISECOND;
			break;
	}

	this.amount = amount;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:29,代碼來源:DateAdjust.java

示例11: getConfiguration

protected StatisticsRetrieverConfiguration getConfiguration() {
  final int rollerInitTrauncateTo = Calendar.DAY_OF_MONTH;
  final int statisticsSize = DEFAULT_STATS_DAYS;
  final int rollerStep = Calendar.DAY_OF_MONTH;
  final int cutOffBefore = Calendar.MONTH;
  return new StatisticsRetrieverConfiguration(rollerInitTrauncateTo,
          statisticsSize,
          rollerStep,
          cutOffBefore);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:DailyPersistentTestStatsRetriever.java

示例12: getMethod

static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case GETVALUE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case ISEMPTY_METHOD:
            return new EmptyMemberValueSource(fieldData);
        case SIZE_METHOD:
            return new CountMethodValueSource(fieldData);
        case MINIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case MAXIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
        case AVERAGE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
        case MEDIAN_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
        case SUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
        case COUNT_METHOD:
            return new CountMethodValueSource(fieldData);
        case GET_YEAR_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.YEAR);
        case GET_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MONTH);
        case GET_DAY_OF_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.DAY_OF_MONTH);
        case GET_HOUR_OF_DAY_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.HOUR_OF_DAY);
        case GET_MINUTES_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MINUTE);
        case GET_SECONDS_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.SECOND);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for date field [" + fieldName + "].");
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:36,代碼來源:DateField.java

示例13: getConfiguration

protected StatisticsRetrieverConfiguration getConfiguration() {
  final int rollerInitTrauncateTo = Calendar.MONTH;
  final int statisticsSize = DEFAULT_STATS_MONTHS;
  final int rollerStep = Calendar.MONTH;
  final int cutOffBefore = Calendar.YEAR;
  return new StatisticsRetrieverConfiguration(rollerInitTrauncateTo,
          statisticsSize,
          rollerStep,
          cutOffBefore);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:MonthlyPersistentBuildStatsRetriever.java

示例14: compareDate

/**
 * 根據單位字段比較兩個日期
 * 
 * @param date
 *            日期1
 * @param otherDate
 *            日期2
 * @param withUnit
 *            單位字段,從Calendar field取值
 * @return 等於返回0值, 大於返回大於0的值 小於返回小於0的值
 */
public static int compareDate(Date date, Date otherDate, int withUnit) {
	Calendar dateCal = Calendar.getInstance();
	dateCal.setTime(date);
	Calendar otherDateCal = Calendar.getInstance();
	otherDateCal.setTime(otherDate);

	switch (withUnit) {
	case Calendar.YEAR:
		dateCal.clear(Calendar.MONTH);
		otherDateCal.clear(Calendar.MONTH);
	case Calendar.MONTH:
		dateCal.set(Calendar.DATE, 1);
		otherDateCal.set(Calendar.DATE, 1);
	case Calendar.DATE:
		dateCal.set(Calendar.HOUR_OF_DAY, 0);
		otherDateCal.set(Calendar.HOUR_OF_DAY, 0);
	case Calendar.HOUR:
		dateCal.clear(Calendar.MINUTE);
		otherDateCal.clear(Calendar.MINUTE);
	case Calendar.MINUTE:
		dateCal.clear(Calendar.SECOND);
		otherDateCal.clear(Calendar.SECOND);
	case Calendar.SECOND:
		dateCal.clear(Calendar.MILLISECOND);
		otherDateCal.clear(Calendar.MILLISECOND);
	case Calendar.MILLISECOND:
		break;
	default:
		throw new IllegalArgumentException("withUnit 單位字段 " + withUnit + " 不合法!!");
	}
	return dateCal.compareTo(otherDateCal);
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:43,代碼來源:DateUtils.java

示例15: getDateFieldFromRepeatType

private static int getDateFieldFromRepeatType(ReminderRepeatType repeatType) {

        switch (repeatType) {
            case DAILY: return Calendar.DAY_OF_MONTH;
            case WEEKLY: return Calendar.WEEK_OF_YEAR;
            case MONTHLY: return Calendar.MONTH;
            case YEARLY: return Calendar.YEAR;
            default: throw new InvalidParameterException("Invalid RepeatType parameter in TaskUtil.getRepeatingReminderEndCalendar()");
        }
    }
 
開發者ID:abicelis,項目名稱:Remindy,代碼行數:10,代碼來源:TaskUtil.java


注:本文中的java.util.Calendar.MONTH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。