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());
    }
    }
  • 相关阅读:
    制作windows服务
    DTCMS部署错误
    mysql常用操作
    eclipse maven jdk全局设置
    linux下安装lnmp环境
    aliyun阿里云Maven仓库地址——加速你的maven构建
    移动端前端框架UI库(Frozen UI、WeUI、SUI Mobile)
    getFields和getDeclaredFields
    2016暑假集训第三次训练赛题解
    HDU5863 cjj's string game(DP + 矩阵快速幂)
  • 原文地址:https://www.cnblogs.com/jabez1992/p/14024043.html
Copyright © 2011-2022 走看看