第一节 使用HuTool工具实现类型转换

亮子 2023-11-25 14:16:51 20227 0 0 0
    @ApiOperation("Convert使用:类型转换工具类")
    @GetMapping(value = "/covert")
    public CommonResult covert() {
        //转换成字符串
        int a = 1;
        String aStr = Convert.toStr(a);
        //转换为指定类型数组
        String[] b = {"1","2","3","4"};
        Integer[] bArr = Convert.toIntArray(b);
        //转换成日期对象
        String dateStr = "2017-07-22";
        Date date = Convert.toDate(dateStr);
        //转换成列表
        String[] strArr = {"a","b","c","d"};
        List<String> strList = Convert.toList(String.class, strArr);
        return CommonResult.success(null,"操作成功");
    }