本文整理汇总了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;
}
});
}
示例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);
}
示例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));
}