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


Java DateUtils.toCalendar方法代碼示例

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


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

示例1: put

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
public void put(final RequestInfo requestInfo) {
    final AppInfo appInfo = requestInfo.getAppInfo();
    final InterfaceInfo interfaceInfo = requestInfo.getInterfaceInfo();
    Date now = new Date();
    Calendar calendar = DateUtils.toCalendar(now);
    final String minuteIndex = getCurrentMinuteIndex(calendar);
    final String currentDay = getCurrentDay(calendar);

    final long cost = requestInfo.getEndTime() - requestInfo.getStartTime();

    final String interfaceCostKey = KeyRole.INTERFACE_COST.getRedisKey(appInfo, interfaceInfo, currentDay);
    final String interfaceKey = KeyRole.INTERFACE.getRedisKey(appInfo, interfaceInfo, currentDay);
    final String appInterfaceKey = KeyRole.APP_INTERFACE.getRedisKey(appInfo, interfaceInfo, currentDay);
    this.redisConfig.execute(new RedisCallback<Object>() {
        @Override
        public Object call(Jedis jedis) {
            Pipeline pipeline = jedis.pipelined();
            // 隻有成功的,才有必要統計請求延遲
            if (requestInfo.isSuccessed()) {
                pipeline.hincrBy(interfaceCostKey, minuteIndex, cost);
            }
            final String filed = requestInfo.isSuccessed() ? minuteIndex + "s" : minuteIndex + "f";
            pipeline.hincrBy(interfaceKey, filed, 1);
            pipeline.hincrBy(appInterfaceKey, filed, 1);
            pipeline.sync();

            if (requestInfo.isSuccessed()) {
                expire(jedis, interfaceCostKey);
            }
            expire(jedis, interfaceKey);
            expire(jedis, appInterfaceKey);
            return null;
        }
    });

}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:37,代碼來源:StatisticsCacheServiceAbstract.java

示例2: getTime

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * Return the milliseconds of given date. Year, month and day fields are ignored.
 */
private long getTime(final Date date) {
	final Calendar calendar = DateUtils.toCalendar(date);
	return calendar.get(Calendar.HOUR_OF_DAY) * DateUtils.MILLIS_PER_HOUR + calendar.get(Calendar.MINUTE) * DateUtils.MILLIS_PER_MINUTE
			+ calendar.get(Calendar.SECOND) * DateUtils.MILLIS_PER_SECOND + calendar.get(Calendar.MILLISECOND);
}
 
開發者ID:ligoj,項目名稱:plugin-bt,代碼行數:9,代碼來源:ComputationContext.java

示例3: joinYearMonthValues

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * @param date
 * @return aggregated year and month values of given date field. Month is counted from 0
 * <p/>
 * For example:
 * If date is 2015-02-03 then return value will be 201501
 */
public static int joinYearMonthValues(Date date) {
  Calendar calendar = DateUtils.toCalendar(date);
  return joinYearMonthValues(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH));
}
 
開發者ID:YagelNasManit,項目名稱:environment.monitor,代碼行數:12,代碼來源:DataUtils.java


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