下面列出了怎么用org.apache.commons.lang3.time.DateFormatUtils的API类实例代码及写法,或者点击链接到github查看源代码。
public static void init() {
timeConvertForm = getInstance();
ThreadUtil.execute(() -> {
while (true) {
timeConvertForm.getCurrentTimestampLabel().setText(String.valueOf(System.currentTimeMillis() / 1000));
timeConvertForm.getCurrentGmtLabel().setText(DateFormatUtils.format(new Date(), TIME_FORMAT));
ThreadUtil.safeSleep(1000);
}
});
if ("".equals(timeConvertForm.getTimestampTextField().getText())) {
timeConvertForm.getTimestampTextField().setText(String.valueOf(System.currentTimeMillis()));
}
if ("".equals(timeConvertForm.getGmtTextField().getText())) {
timeConvertForm.getGmtTextField().setText(DateFormatUtils.format(new Date(), TIME_FORMAT));
}
timeConvertForm.getTimeConvertPanel().updateUI();
}
/**
* save for manual
*/
private static void saveImage() {
if (StringUtils.isEmpty(selectedName)) {
selectedName = "未命名_" + DateFormatUtils.format(new Date(), "yyyy-MM-dd_HH-mm-ss");
}
String name = JOptionPane.showInputDialog("名称", selectedName);
if (StringUtils.isNotBlank(name)) {
try {
if (selectedImage != null) {
File imageFile = FileUtil.touch(new File(IMAGE_PATH_PRE_FIX + name + ".png"));
ImageIO.write(ImageUtil.toBufferedImage(selectedImage), "png", imageFile);
ImageForm.initListTable();
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(App.mainFrame, "保存失败!\n\n" + ex.getMessage(), "失败", JOptionPane.ERROR_MESSAGE);
log.error(ExceptionUtils.getStackTrace(ex));
}
}
}
public static List<String> getLineChartCategories(String dateVal, int dataSize) throws Exception {
List<String> categories = new LinkedList<String>();
if (dataSize < 0) {
throw new ServiceException("data-size error!");
}
Date endDate = DateUtils.parseDate(dateVal, new String[]{"yyyyMMdd"});
int dateRange = dataSize -1;
if (dateRange < 0) {
dateRange = 0;
}
if (dateRange == 0) {
categories.add( DateFormatUtils.format(endDate, "yyyy/MM/dd") );
return categories;
}
Date startDate = DateUtils.addDays(endDate, (dateRange * -1) );
for (int i=0; i<dataSize; i++) {
Date currentDate = DateUtils.addDays(startDate, i);
String currentDateStr = DateFormatUtils.format(currentDate, "yyyy/MM/dd");
categories.add(currentDateStr);
}
return categories;
}
/**
* @param documentContainer
* @param node
* @throws InvalidSPDXAnalysisException
*/
public SpdxDocument(SpdxDocumentContainer documentContainer, Node node)
throws InvalidSPDXAnalysisException {
super(documentContainer, node);
this.documentContainer = documentContainer;
getMyPropertiesFromModel();
if (this.getCreationInfo() == null){
String licenseListVersion = ListedLicenses.getListedLicenses().getLicenseListVersion();
String creationDate = DateFormatUtils.format(Calendar.getInstance(), SpdxRdfConstants.SPDX_DATE_FORMAT);
SPDXCreatorInformation creationInfo = new SPDXCreatorInformation(new String[] { }, creationDate, null, licenseListVersion);
setCreationInfo(creationInfo);
}
else if (StringUtils.isBlank(this.getCreationInfo().getLicenseListVersion())){
this.getCreationInfo().setLicenseListVersion(ListedLicenses.getListedLicenses().getLicenseListVersion());
}
}
public void generate() throws GlobalConfigException {
Configuration cfg = new Configuration();
File tmplDir = globalConfig.getTmplFile();
try {
cfg.setDirectoryForTemplateLoading(tmplDir);
} catch (IOException e) {
throw new GlobalConfigException("tmplPath", e);
}
cfg.setObjectWrapper(new DefaultObjectWrapper());
for (Module module : modules) {
logger.debug("module:" + module.getName());
for (Bean bean : module.getBeans()) {
logger.debug("bean:" + bean.getName());
Map dataMap = new HashMap();
dataMap.put("bean", bean);
dataMap.put("module", module);
dataMap.put("generate", generate);
dataMap.put("config", config);
dataMap.put("now", DateFormatUtils.ISO_DATE_FORMAT.format(new Date()));
generate(cfg, dataMap);
}
}
}
@Test
public void loginTest() throws SignatureException {
Subject subject = SecurityUtils.getSubject();
String date = DateFormatUtils.SMTP_DATETIME_FORMAT.format(new Date());
String resource = "/questionnaires/58";
String method = "GET";
String stringToSign = new StringBuilder().append(method).append(" ").append(resource).append("\n").append(date)
.toString();
String apiKey = "B868UOHUTKUDWXM";
String secret = "IQO27YUZO8NJ7RADIK6SJ9BQZNYP4EMO";
String signature = HMACSignature.calculateRFC2104HMAC(stringToSign, secret);
AuthenticationToken token = new HmacAuthToken.Builder().apiKey(apiKey).signature(signature).dateUTC(date)
.message(stringToSign).build();
subject.login(token);
assertThat(subject.getPrincipal()).isInstanceOf(User.class);
assertThat(subject.getPrincipal()).isEqualTo(User.with().id(3).build());
boolean isPermitted = subject.isPermitted("questionnaire:read:58");
assertThat(isPermitted).isTrue();
}
protected static String getStringRepOfFieldValueForInsert(Field field) {
switch (field.getType()) {
case BYTE_ARRAY:
//Do a hex encode.
return Hex.encodeHexString(field.getValueAsByteArray());
case BYTE:
return String.valueOf(field.getValueAsInteger());
case TIME:
return DateFormatUtils.format(field.getValueAsDate(), "HH:mm:ss.SSS");
case DATE:
return DateFormatUtils.format(field.getValueAsDate(), "yyyy-MM-dd");
case DATETIME:
return DateFormatUtils.format(field.getValueAsDate(), "yyyy-MM-dd HH:mm:ss.SSS");
case ZONED_DATETIME:
return DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(
field.getValueAsZonedDateTime().toInstant().toEpochMilli()
);
default:
return String.valueOf(field.getValue());
}
}
/**
* 文件上传接口测试
*/
@Test
public void fileuploadTest() throws IOException {
//入参
String appid = "670";
String appsecret = "cPs6euPuvtsru2I3vmYb2Q";
String partnerApplyNo = JadyerUtil.randomNumeric(16);
String filepath = "D:\\JavaSE\\Picture\\Wallpaper\\观海云远.jpg";
String reqURL = "http://127.0.0.1/open/router/rest";
//调用
Map<String, String> dataMap = new HashMap<>();
dataMap.put("partnerApplyNo", partnerApplyNo);
Map<String, String> paramMap = new HashMap<>();
paramMap.put("appid", appid);
paramMap.put("version", SeedConstants.OPEN_VERSION_21);
paramMap.put("method", SeedConstants.OPEN_METHOD_boot_file_upload);
paramMap.put("timestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
paramMap.put("data", CodecUtil.buildAESEncrypt(JSON.toJSONString(dataMap), appsecret));
HTTPUtil.upload(reqURL, "观海云远.jpg", FileUtils.openInputStream(new File(filepath)), "fileData", paramMap);
}
/**
* 申请单查询接口
*/
@Test
public void loanGetViaAES(){
//入参
String appid = "770";
String appsecret = "PDlTxZ8Vql5Y8owPSU6hzw";
String applyNo = JadyerUtil.randomNumeric(16);
String partnerApplyNo = JadyerUtil.randomNumeric(16);
String reqURL = "http://127.0.0.1/open/router/rest";
//调用
Map<String, String> dataMap = new HashMap<>();
dataMap.put("applyNo", applyNo);
dataMap.put("partnerApplyNo", partnerApplyNo);
Map<String, String> paramMap = new HashMap<>();
paramMap.put("appid", appid);
paramMap.put("version", SeedConstants.OPEN_VERSION_21);
paramMap.put("method", SeedConstants.OPEN_METHOD_boot_loan_get);
paramMap.put("timestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
paramMap.put("data", CodecUtil.buildAESEncrypt(JSON.toJSONString(dataMap), appsecret));
String respData = HTTPUtil.post(reqURL, JSON.toJSONString(paramMap), "application/json; charset=UTF-8");
Map<String, String> respMap = JSON.parseObject(respData, new TypeReference<Map<String, String>>(){});
if("0".equals(respMap.get("code"))){
System.out.println("解密后的明文为-->" + CodecUtil.buildAESDecrypt(respMap.get("data"), appsecret));
}
}
/**
* FTP上传测试
*/
@Test
public void FTPUtilForUploadTest() throws IOException {
//InputStream is = FileUtils.openInputStream(new File("E:\\Wallpaper\\三大名迹.jpg"));
//String remoteURL = "/mytest/02/03/" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + ".jpg";
//Assert.assertTrue(FTPUtil.upload("192.168.2.60", "ftpupload", "HUvueMGWg92y8SSN", remoteURL, is));
//is = FileUtils.openInputStream(new File("E:\\Wallpaper\\Wentworth.Miller.jpg"));
//remoteURL = "/mytest/02/03/" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss_2") + ".jpg";
//Assert.assertTrue(FTPUtil.upload("192.168.2.60", "ftpupload", "HUvueMGWg92y8SSN", remoteURL, is));
//FTPUtil.logout();
InputStream is = FileUtils.openInputStream(new File("F:\\Tool\\Enterprise_Architect_8.0.858.zip"));
String remoteURL = "/mytest/02/03/" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + ".jpg";
Assert.assertTrue(FTPUtil.uploadAndLogout("192.168.2.60", "ftpupload", "HUvueMGWg92y8SSN", remoteURL, is));
}
/**
* 获取一天开始时间
*
* @param date
* @return
*/
public static Date getDayBegin(Date date) {
String format = DateFormatUtils.format(date, DATE_PATTERN);
try {
return parseDate(format.concat(" 00:00:00"), TIMESTAMP_PATTERN);
} catch (ParseException ex) {
return null;
}
}
/**
* 获取一天结束时间
*
* @param date
* @return
*/
public static Date getDayEnd(Date date) {
String format = DateFormatUtils.format(date, DATE_PATTERN);
try {
return parseDate(format.concat(" 23:59:59"), TIMESTAMP_PATTERN);
} catch (ParseException ex) {
return null;
}
}
/**
* 格式化日期为日期字符串<br>
* generate by: vakin jiang at 2012-3-7
*
* @param orig
* @param patterns
* @return
*/
public static String format(Date date, String... patterns) {
if (date == null)
return "";
String pattern = TIMESTAMP_PATTERN;
if (patterns != null && patterns.length > 0
&& StringUtils.isNotBlank(patterns[0])) {
pattern = patterns[0];
}
return DateFormatUtils.format(date, pattern);
}
private static Duration durationBuilder() {
Date endDate = new Date();
String end = DateFormatUtils.format(endDate, "yyyy-MM-dd HHmm");
Date StartDate = DateUtils.addMinutes(endDate, -15);
String start = DateFormatUtils.format(StartDate, "yyyy-MM-dd HHmm");
Duration duration = new Duration();
duration.setStart(start);
duration.setEnd(end);
duration.setStep("MINUTE");
return duration;
}
/**
* Generate an encryption context (additional information about the payload). This context is not
* encrypted and should not contain secrets.
*/
protected Map<String, String> buildEncryptionContext(String sdbPath) {
Map<String, String> context = new HashMap<>();
context.put("created_on", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
context.put(SDB_PATH_PROPERTY_NAME, sdbPath);
return context;
}
@Test
public void handleRequestTest() throws SignatureException, IOException {
ContainerRequestContext requestContext = createMock(ContainerRequestContext.class);
ClassResourceInfo resourceClass = createMock(ClassResourceInfo.class);
HttpHeaders headers = createMock(HttpHeaders.class);
UriInfo uriInfo = createMock(UriInfo.class);
String date = DateFormatUtils.SMTP_DATETIME_FORMAT.format(new Date());
String resource = "/questionnaires/61";
String method = "GET";
String stringToSign = new StringBuilder().append(method).append(" ").append(resource).append("\n").append(date)
.toString();
String apiKey = "B868UOHUTKUDWXM";
String secret = "IQO27YUZO8NJ7RADIK6SJ9BQZNYP4EMO";
String signature = HMACSignature.calculateRFC2104HMAC(stringToSign, secret);
String authToken = generateAuth(apiKey, signature);
expect(requestContext.getMethod()).andReturn(method);
expect(uriInfo.getRequestUri()).andReturn(URI.create("http://localhost:8080/gazpachoquest-rest-web/api/" + resource));
expect(requestContext.getHeaderString(HttpHeaders.AUTHORIZATION)).andReturn(authToken);
expect(requestContext.getHeaderString(HttpHeaders.DATE)).andReturn(date);
expect(headers.getRequestHeader(HttpHeaders.AUTHORIZATION)).andReturn(Arrays.asList(authToken));
expect(headers.getRequestHeader(HttpHeaders.DATE)).andReturn(Arrays.asList(date));
expect(uriInfo.getPath()).andReturn(resource.substring(1));
replay(requestContext,resourceClass, uriInfo, headers);
loginShiroFilter.setUriInfo(uriInfo);
loginShiroFilter.setHeaders(headers);
loginShiroFilter.filter(requestContext);
}
private List<String> listDate(Date beginDate, Date endDate) {
List<String> dateList = new ArrayList<>();
dateList.add(DateFormatUtils.format(beginDate, simpleDateFormat));
Calendar calBegin = Calendar.getInstance();
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(endDate);
calBegin.setTime(beginDate);
while (endDate.after(calBegin.getTime())) {
calBegin.add(Calendar.DAY_OF_MONTH, 1);
dateList.add(DateFormatUtils.format(calBegin.getTime(), simpleDateFormat));
}
return dateList;
}
private UploadInfo createExpiredUploadInfo() throws ParseException {
final long time = DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.parse("2018-01-20T10:43:11").getTime();
return new UploadInfo() {
@Override
protected long getCurrentTime() {
return getExpirationTimestamp() == null ? time : time + 10000L;
}
};
}
private boolean inDefinedHoliday(Calendar c) {
if (ArrayUtils.isNotEmpty(this.definedHolidays)) {
if (ArrayUtils.indexOf(this.definedHolidays,
DateFormatUtils.format(c, DATEPARTFORMATPATTERN[0])) > ArrayUtils.INDEX_NOT_FOUND) {
return true;
}
}
return false;
}
/**
* 格式化日期为指定格式<br>
* generate by: vakin jiang at 2012-3-7
*
* @param orig
* @param patterns
* @return
*/
public static Date formatDate(Date orig, String... patterns) {
String pattern = TIMESTAMP_PATTERN;
if (patterns != null && patterns.length > 0
&& StringUtils.isNotBlank(patterns[0])) {
pattern = patterns[0];
}
return parseDate(DateFormatUtils.format(orig, pattern));
}
/**
* 根据配置重新设置 imageName
*
* @param data the data
* @param imageIterator the image iterator
* @param markdownImage the markdown image
* @return the boolean
*/
@Override
public void invoke(EventData data, Iterator<MarkdownImage> imageIterator, MarkdownImage markdownImage) {
String imageName = markdownImage.getImageName();
MikState state = MikPersistenComponent.getInstance().getState();
// 处理文件名有空格导致上传 gif 变为静态图的问题
imageName = imageName.replaceAll("\\s*", "");
int sufixIndex = state.getSuffixIndex();
Optional<SuffixEnum> sufix = EnumsUtils.getEnumObject(SuffixEnum.class, e -> e.getIndex() == sufixIndex);
SuffixEnum suffixEnum = sufix.orElse(SuffixEnum.FILE_NAME);
switch (suffixEnum) {
case FILE_NAME:
break;
case DATE_FILE_NAME:
// 删除原来的时间前缀
imageName = imageName.replace(DateFormatUtils.format(new Date(), "yyyy-MM-dd-"), "");
imageName = DateFormatUtils.format(new Date(), "yyyy-MM-dd-") + imageName;
break;
case RANDOM:
if(!imageName.startsWith(PREFIX)){
imageName = PREFIX + CharacterUtils.getRandomString(6) + ImageUtils.getFileExtension(imageName);
}
break;
default:
break;
}
markdownImage.setImageName(imageName);
}
/**
* 动态表示方式的时间差函数
*
* @param startDate
* 指定时间
* @param endDate
* 结束时间
* @return 时间差指定格式字符串
*/
public static String dynDiff(Date startDate, Date endDate) {
String startDay = DateFormatUtils.format(startDate, "dd");
String endtDay = DateFormatUtils.format(endDate, "dd");
String value = "";
if (startDay.equals(endtDay)) {
value = DateFormatUtils.format(startDate, " HH:mm");
} else {
value = otherDiff(startDate, endDate);
}
return value;
}
/**
* 资源表示方式的时间差函数
*
* @param startDate
* 指定时间
* @param endDate
* 结束时间
* @return 时间差指定格式字符串
*/
public static String resDiff(Date startDate, Date endDate) {
Object[] obj = timeDifference(startDate, endDate);
String value = "";
if (Long.parseLong(obj[3].toString()) > 7) {
value = DateFormatUtils.format(startDate, "yyyy-MM-dd HH:mm");
} else {
value = otherDiff(startDate, endDate);
}
return value;
}
private void initReceiverTimes(){
todayStartTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd 00:00:00");
todayEndTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd 23:59:59");
allStartTime = DateFormatUtils.format(new Date(), "10000-01-01 00:00:00");
allEndTime = DateFormatUtils.format(new Date(), "9999-12-31 23:59:59");
nowStartTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
@Override
public boolean sendMsg(int jobId, Properties props, Logger log) {
boolean result = false;
PreparedStatement pstmt = null;
Connection msgConn = null;
String sendTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
String sqlForSendMsg = "INSERT INTO event_queue (sender,send_time,topic,msg_name,msg,send_ip) VALUES(?,?,?,?,?,?)";
try {
String vIP = getLinuxLocalIp(log);
msgConn = getEventCheckerConnection(props,log);
if(msgConn==null) return false;
pstmt = msgConn.prepareCall(sqlForSendMsg);
pstmt.setString(1, sender);
pstmt.setString(2, sendTime);
pstmt.setString(3, topic);
pstmt.setString(4, msgName);
pstmt.setString(5, msg);
pstmt.setString(6, vIP);
int rs = pstmt.executeUpdate();
if (rs == 1) {
result = true;
log.info("Send msg success!");
} else {
log.error("Send msg failed for update database!");
}
} catch (SQLException e) {
throw new RuntimeException("Send EventChecker msg failed!" + e);
} finally {
closeQueryStmt(pstmt, log);
closeConnection(msgConn, log);
}
return result;
}
private Date stamp(String memo) {
Date date = new Date();
long total = date.getTime() - start.getTime();
Log pre = logs.get(logs.size() - 1);
long elapsed = date.getTime() - pre.getDate().getTime();
System.out.println(
"ClockStamp(" + this.name + ") start at(" + DateFormatUtils.format(date, FORMAT) + "), arrived(" + memo
+ ") total(" + total + ")ms, form(" + pre.getMemo() + ") elapsed(" + elapsed + ")ms.");
Log log = new Log(memo, date, elapsed);
logs.add(log);
return date;
}
@RequestMapping("{cacheName}/{key}/details")
@ResponseBody
public Object keyDetail(
@PathVariable("cacheName") String cacheName,
@PathVariable("key") String key,
Model model
) {
Element element = cacheManager.getCache(cacheName).get(key);
String dataPattern = "yyyy-MM-dd hh:mm:ss";
Map<String, Object> data = Maps.newHashMap();
data.put("objectValue", element.getObjectValue().toString());
data.put("size", PrettyMemoryUtils.prettyByteSize(element.getSerializedSize()));
data.put("hitCount", element.getHitCount());
Date latestOfCreationAndUpdateTime = new Date(element.getLatestOfCreationAndUpdateTime());
data.put("latestOfCreationAndUpdateTime", DateFormatUtils.format(latestOfCreationAndUpdateTime, dataPattern));
Date lastAccessTime = new Date(element.getLastAccessTime());
data.put("lastAccessTime", DateFormatUtils.format(lastAccessTime, dataPattern));
if(element.getExpirationTime() == Long.MAX_VALUE) {
data.put("expirationTime", "不过期");
} else {
Date expirationTime = new Date(element.getExpirationTime());
data.put("expirationTime", DateFormatUtils.format(expirationTime, dataPattern));
}
data.put("timeToIdle", element.getTimeToIdle());
data.put("timeToLive", element.getTimeToLive());
data.put("version", element.getVersion());
return data;
}
@Test
public void testGetVisitDistribution() throws Exception {
final WxMaAnalysisService service = wxMaService.getAnalysisService();
Date twoDaysAgo = DateUtils.addDays(new Date(), -2);
WxMaVisitDistribution distribution = service.getVisitDistribution(twoDaysAgo, twoDaysAgo);
assertNotNull(distribution);
String date = DateFormatUtils.format(twoDaysAgo, "yyyyMMdd");
assertEquals(date, distribution.getRefDate());
assertTrue(distribution.getList().containsKey("access_source_session_cnt"));
assertTrue(distribution.getList().containsKey("access_staytime_info"));
assertTrue(distribution.getList().containsKey("access_depth_info"));
System.out.println(distribution);
}
private void uploadStormJars(String user, String host, String port, String homePath, String category, String type, String jarName) {
long time = System.currentTimeMillis();
String minorVersion = StringUtils.join(new String[]{DateFormatUtils.format(time, "yyyyMMdd"), DateFormatUtils.format(time, "HHmmss")}, "_");
String savePath = StringUtils.join(new String[]{homePath, KeeperConstants.RELEASE_VERSION, type, minorVersion}, "/");
String cmd = MessageFormat.format("ssh -p {0} {1}@{2} mkdir -pv {3}", port, user, host, savePath);
logger.info("mdkir command: {}", cmd);
int retVal = execCmd(cmd, null);
if (retVal == 0) {
logger.info("mkdir success.");
File file = new File(SystemUtils.getUserDir() + "/../extlib/" + jarName);
cmd = MessageFormat.format("scp -P {0} {1} {2}@{3}:{4}", port, file.getPath(), user, host, savePath + "/" + jarName);
logger.info("scp command: {}", cmd);
retVal = execCmd(cmd, null);
if (retVal == 0) {
logger.info("scp success.");
}
}
TopologyJar topologyJar = new TopologyJar();
topologyJar.setName(jarName);
topologyJar.setCategory(category);
topologyJar.setVersion(KeeperConstants.RELEASE_VERSION);
topologyJar.setType(type);
topologyJar.setMinorVersion(minorVersion);
topologyJar.setPath(savePath + "/" + jarName);
topologyJar.setCreateTime(new Date());
topologyJar.setUpdateTime(new Date());
topologyJarMapper.insert(topologyJar);
}
private StringBuilder map2json(StringBuilder stringBuilder, Map<String, Object> map) {
if (!map.isEmpty()) {
int size = map.size();
for (Map.Entry<String, Object> entry : map.entrySet()) {
//key print
stringBuilder.append(QUOTE).append(entry.getKey()).append(QUOTE).append(COLON);
//key:tags,tags:value
if (entry.getValue() instanceof Map) {
stringBuilder.append(BRACES_LEFT);
map2json(stringBuilder, (Map<String, Object>) entry.getValue());
stringBuilder.append(BRACES_RIGHT);
}
//key:time,time:value
else if (entry.getValue() instanceof Date) {
String timestamp = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT
.format((Date) (entry.getValue()));
stringBuilder.append(QUOTE).append(timestamp).append(QUOTE);
}
//value:number
else if (entry.getValue() instanceof Number) {
stringBuilder.append(entry.getValue());
} else {
stringBuilder.append(QUOTE)
.append(StringEscapeUtils.escapeJson(entry.getValue().toString()))
.append(QUOTE);
}
if (--size > 0) {
stringBuilder.append(COMMA);
}
}
}
return stringBuilder;
}