Java对字符串32位的uuid添加上横杠

StringBuffer stringBuilder=new StringBuffer("f7504588c65a4b99bc20cf1646f58ef1");
                stringBuilder.insert(8,"-");
                stringBuilder.insert(12,"-");
                stringBuilder.insert(16,"-");
                stringBuilder.insert(20,"-");
// 校验是否转换成功
UUID uuid = UUID.fromString(stringBuilder.toString());

 

posted @ 2023-02-08 15:29  迷糊桃  阅读(94)  评论(0编辑  收藏  举报