zoukankan      html  css  js  c++  java
  • 对象转JSON正则查找替换

    package com.smil.gws.wbd.labor;

    import com.alibaba.fastjson.JSON;
    import com.alibaba.fastjson.JSONObject;
    import com.smil.gws.common.utils.GwsReportUtils;
    import com.smil.gws.report.vo.WcmWarrantyClaimExportView;
    import org.bouncycastle.util.StringList;

    import java.util.*;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    public class test {
    public static void main(String[] args) {
    WcmWarrantyClaimExportView view = new WcmWarrantyClaimExportView();
    view.setStatus("10");
    view.setClaimType("2");
    view.setAdjustAdditionalLaborTimes(null);
    view.setSubmitDate("2020-01-12");
    view.setApproveDate("2020-02-12");
    view.setProductionDate("2020-03-12");
    view.setPurchaseDate("2020-03-12");
    view.setReceptionDate("2020-04-12");
    view.setClaimNo("我是-订单号");
    String ysj = JSON.toJSON(view).toString();
    System.out.println(ysj);
    String pat = "\d{4}-\d{2}-\d{2}";
    Pattern pattern = Pattern.compile(pat);
    Matcher matcher = pattern.matcher(ysj);
    List<String> stringList = new ArrayList<>();
    while(matcher.find()){
    stringList.add(matcher.group());
    }
    for (String s : stringList) {
    if (ysj.contains(s)){
    ysj = ysj.replace("Date":""+s,"Date":""+s.replace("-","/"));
    }
    }
    WcmWarrantyClaimExportView wcmWarrantyClaimExportView = JSONObject.toJavaObject(JSON.parseObject(ysj), WcmWarrantyClaimExportView.class);
    System.out.println(JSON.toJSON(wcmWarrantyClaimExportView).toString());
    }
    }
  • 相关阅读:
    MySQL 数据库常用命令
    HTML常用标签介绍
    浏览器 返回状态码汇总
    Mysql常用的三种数据库引擎比较
    系统常用端口大全
    nginx入门与实战
    Linux系统基础优化及常用命令
    python开发之virtualenv与virtualenvwrapper讲解
    常用服务安装部署
    远程连接Linux
  • 原文地址:https://www.cnblogs.com/jabez1992/p/14024043.html
Copyright © 2011-2022 走看看