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


Java Calendar.DAY_OF_MONTH屬性代碼示例

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


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

示例1: 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

示例2: getDateStart

/**
 * @param dateAndResolution
 * @return String date
 */
public static String getDateStart(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.getActualMinimum(Calendar.MONTH));
        case Calendar.MONTH:
            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
        case Calendar.DAY_OF_MONTH:
            cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
        case Calendar.HOUR_OF_DAY:
            cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
        case Calendar.MINUTE:
            cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
        case Calendar.SECOND:
            cal.set(Calendar.MILLISECOND, cal.getActualMinimum(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: 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

示例4: 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

示例5: isDayDisabledByCriteria

public static boolean isDayDisabledByCriteria(Day day, DisabledDaysCriteria criteria) {
    int field = -1;
    switch (criteria.getCriteriaType()){
        case DAYS_OF_MONTH:
            field = Calendar.DAY_OF_MONTH;
            break;

        case DAYS_OF_WEEK:
            field = Calendar.DAY_OF_WEEK;
            break;
    }

    for(int dayInt : criteria.getDays()){
        if(dayInt == day.getCalendar().get(field)){
            return true;
        }
    }
    return false;
}
 
開發者ID:ApplikeySolutions,項目名稱:CosmoCalendar,代碼行數:19,代碼來源:CalendarUtils.java

示例6: 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

示例7: formatDateDiff

public static String formatDateDiff(Calendar fromDate, Calendar toDate) {
	boolean future = false;
	if (toDate.equals(fromDate)) {
		return I18N.tr("now");
	}
	if (toDate.after(fromDate)) {
		future = true;
	}
	StringBuilder sb = new StringBuilder();
	int[] types = { Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND };
	String[] names = {
		I18N.tr("year"), I18N.tr("years"),
		I18N.tr("month"), I18N.tr("months"),
		I18N.tr("day"), I18N.tr("days"),
		I18N.tr("hour"), I18N.tr("hours"),
		I18N.tr("minute"), I18N.tr("minutes"),
		I18N.tr("second"), I18N.tr("seconds")
	};
	int accuracy = 0;
	for (int i = 0; i < types.length; i++) {
		if (accuracy > 2) {
			break;
		}
		int diff = dateDiff(types[i], fromDate, toDate, future);
		if (diff > 0) {
			accuracy++;
			sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
		}
	}
	if (sb.length() == 0) {
		return "now";
	}
	return sb.toString().trim();
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:34,代碼來源:DateUtils.java

示例8: truncateDate

/**
   * @param date
   * @param truncateAt
   */
  public static Date truncateDate(final Date date, final int truncateAt) {
    final Calendar source = Calendar.getInstance();
    source.clear();
    source.setTime(date);
    final Calendar result = Calendar.getInstance();
    result.clear();
    result.set(Calendar.YEAR, source.get(Calendar.YEAR));
    final TimeZone sourceTimeZone = source.getTimeZone();
    result.setTimeZone(sourceTimeZone);
    if (truncateAt == Calendar.HOUR_OF_DAY) {
      result.set(Calendar.HOUR_OF_DAY, source.get(Calendar.HOUR_OF_DAY));
      result.set(Calendar.MONTH, source.get(Calendar.MONTH));
      result.set(Calendar.DAY_OF_MONTH, source.get(Calendar.DAY_OF_MONTH));
      result.set(Calendar.DST_OFFSET, source.get(Calendar.DST_OFFSET));
    } else if (truncateAt == Calendar.DAY_OF_MONTH) {
      result.set(Calendar.MONTH, source.get(Calendar.MONTH));
      result.set(Calendar.DAY_OF_MONTH, source.get(Calendar.DAY_OF_MONTH));
//      if (log.isDebugEnabled()) log.debug("result.get(Calendar.HOUR_OF_DAY): " + result.get(Calendar.HOUR_OF_DAY));
    } else if (truncateAt == Calendar.MONTH) {
      result.set(Calendar.MONTH, source.get(Calendar.MONTH));
    } else if (truncateAt == Calendar.YEAR) { // NOPMD
      // do nothing
    } else { // NOPMD
      throw new IllegalArgumentException("Unknown truncateAt");
    }
    return result.getTime();
  }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:31,代碼來源:StatisticsUtils.java

示例9: 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

示例10: getConfiguration

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


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