Example #1
0
 public static Date tranSinaApiDate(String timeStr) {
   try {
     return DateFormatterThreadLocal.getSinaApiDateFormat().parse(timeStr);
   } catch (ParseException e) {
     logger.error("Exception:{}", LogbackUtil.expection2Str(e));
     throw new RuntimeException(e);
   }
 }
Example #2
0
 /**
  * 将"2014-08-25 00:00:00"转换为long型时间戳
  *
  * @param str
  * @return
  */
 public static long transTimeLong(String str) {
   try {
     Date date = DateFormatterThreadLocal.getLongDateFormat().parse(str);
     return date.getTime();
   } catch (ParseException e) {
     logger.error("Exception:{}", LogbackUtil.expection2Str(e));
     throw new RuntimeException(e);
   }
 }
Example #3
0
 public static long transSolrReturnStrToMilli(String str) {
   try {
     return DateFormatterThreadLocal.getSolrReturnDateFormat().parse(str).getTime();
   } catch (ParseException e) {
     logger.error("Exception:{}", LogbackUtil.expection2Str(e));
     return 0L;
     //			throw new RuntimeException();
   }
 }
Example #4
0
 /** 将Solr返回的时间串转换成可读性较好的格式 如:Thu Apr 10 11:40:56 CST 2014——>2014-04-10 10:07:14 */
 public static String transStrToCommonDateStr(String str) {
   try {
     return DateFormatterThreadLocal.getLongDateFormat()
         .format(DateFormatterThreadLocal.getSolrReturnDateFormat().parse(str));
   } catch (ParseException e) {
     logger.error("Exception:{}", LogbackUtil.expection2Str(e));
     return "";
     //			throw new RuntimeException();
   }
 }
Example #5
0
 static {
   logger.info("Load resource: kafka.properties");
   try (InputStream in =
       ConfigUtil.class.getClassLoader().getResourceAsStream("kafka.properties"); ) {
     props.load(in);
     logger.info("kafka properties : " + props.toString());
   } catch (Exception e) {
     logger.error("Exception:{}", LogbackUtil.expection2Str(e));
     throw new RuntimeException(e);
   }
 }