补充各种无数据情况
This commit is contained in:
@@ -4,18 +4,18 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* 日期工具类, 继承org.apache.commons.lang.time.DateUtils类
|
||||
* @author ThinkGem
|
||||
@@ -232,7 +232,28 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
}
|
||||
return timeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将短时间格式字符串转换为时间 yyyy-MM-dd
|
||||
*
|
||||
* @param strDate
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 将短时间格式字符串转换为指定时间
|
||||
*
|
||||
* @param strDate
|
||||
* @param dateFormat "yyyy-MM-dd HH:mm:ss" 此参数为空,默认为:"yyyy-MM-dd"
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date strToDate(String strDate,String dateFormat) throws ParseException {
|
||||
if(dateFormat==null || "".equals(dateFormat)){
|
||||
dateFormat = "yyyy-MM-dd";
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
||||
Date strtodate = sdf.parse(strDate);
|
||||
return strtodate;
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
* @throws ParseException
|
||||
|
||||
@@ -6,18 +6,19 @@ import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
public class JedisUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(JedisUtils.class);
|
||||
|
||||
private static final JedisPool jedisPool = SpringContextHolder.getBean(JedisPool.class);
|
||||
/**
|
||||
* 获取缓存
|
||||
*
|
||||
@@ -212,15 +213,13 @@ public class JedisUtils {
|
||||
* @throws JedisException
|
||||
*/
|
||||
public static Jedis getResource(int redisDb) throws JedisException {
|
||||
JedisSentinelPool jedisSentinelPool = SpringContextHolder.getBean(JedisSentinelPool.class);
|
||||
|
||||
if (jedisSentinelPool == null) {
|
||||
Jedis jedis = null;
|
||||
if (jedisPool == null) {
|
||||
throw new ServiceRuntimeException("redis连接池为空,请联系管理员检查程序",
|
||||
RestBusinessCode.CannotConnectionRedis.getValue());
|
||||
}
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisSentinelPool.getResource();
|
||||
jedis = jedisPool.getResource();
|
||||
jedis.select(redisDb);
|
||||
} catch (JedisException e) {
|
||||
returnBrokenResource(jedis);
|
||||
|
||||
Reference in New Issue
Block a user