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