Java Code Examples for com.alibaba.fastjson.JSONObject#toJSONStringWithDateFormat()

The following examples show how to use com.alibaba.fastjson.JSONObject#toJSONStringWithDateFormat() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
* 切换方法,记录日志
* @param joinPoint
* @return
* @throws Throwable
*/
 @Around("serviceLog()")
  public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
      MethodSignature signature = (MethodSignature) joinPoint.getSignature();
      Method method = signature.getMethod();
      Class<?> targetClass = method.getDeclaringClass();

      StringBuffer classAndMethod = new StringBuffer();

      Log classAnnotation = targetClass.getAnnotation(Log.class);
      Log methodAnnotation = method.getAnnotation(Log.class);

      if (classAnnotation != null) {
          if (classAnnotation.ignore()) {
              return joinPoint.proceed();
          }
          classAndMethod.append(classAnnotation.value()).append("-");
      }

      if (methodAnnotation != null) {
          if (methodAnnotation.ignore()) {
              return joinPoint.proceed();
          }
          classAndMethod.append(methodAnnotation.value());
      }

      String target = targetClass.getName() + "#" + method.getName();

      String params = null;
           params = JSONObject.toJSONStringWithDateFormat(joinPoint.getArgs(), dateFormat, SerializerFeature.WriteMapNullValue);

      log.info(STRING_START + "{} 开始调用--> {} 参数:{}", classAndMethod.toString(), target, params);

      long start = System.currentTimeMillis();
      Object result = joinPoint.proceed();
      long timeConsuming = System.currentTimeMillis() - start;

      log.info("\n{} 调用结束<-- {} 返回值:{} 耗时:{}ms" + STRING_END, classAndMethod.toString(), target, JSONObject.toJSONStringWithDateFormat(result, dateFormat, SerializerFeature.WriteMapNullValue), timeConsuming);
      return result;
  }
 
Example 2
Source Project: xian   File: UnitResponse.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Standard json formation without data lost.
 */
public String toJSONString() {
    if (context.isPretty()) {
        return JSON.toJSONStringWithDateFormat(this, Constant.DATE_SERIALIZE_FORMAT, SerializerFeature.PrettyFormat);
    } else {
        return JSONObject.toJSONStringWithDateFormat(this, Constant.DATE_SERIALIZE_FORMAT);
    }
}
 
Example 3
Source Project: xian   File: UnitResponse.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Our api gateway uses this method instead of {@link #toJSONString()} {@link #toString()} to produce a desensitized output VO json string.
 * For detail, see the return description.
 *
 * @return json string with sensitive properties(the context property) hidden.
 */
public String toVoJSONString() {
    if (context.isPretty()) {
        return JSON.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT, SerializerFeature.PrettyFormat);
    } else {
        return JSONObject.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT);
    }
}
 
Example 4
Source Project: xian   File: UnitResponse.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * No matter context pretty attribute is true or not, this method formats the json string you want.
 *
 * @param pretty pretty or not.
 * @return formatted json string.
 */
public String toVoJSONString(boolean pretty) {
    if (pretty) {
        return JSON.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT, SerializerFeature.PrettyFormat);
    } else {
        return JSONObject.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT);
    }
}
 
Example 5
Source Project: framework   File: FlowConfig.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @return <br>
 */
@Override
public String toString() {
    return JSONObject.toJSONStringWithDateFormat(this, "yyyy-MM-dd HH:mm:ss", new SerializerFeature[0]);
}
 
Example 6
Source Project: framework   File: BaseEntity.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * toString
 * 
 * @see java.lang.Object#toString()
 * @return <br>
 */
@Override
public String toString() {
    return JSONObject.toJSONStringWithDateFormat(this, DateConstants.DATETIME_FORMAT_19);
}