本文整理匯總了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));
}