当前位置: 首页>>代码示例>>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;未经允许,请勿转载。