Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个号码
6430134080234080234080200000000
我想要这种形式:
643,01,340802,340802,340802,00000000
我的目标是将其插入数据库。
首先,您显然没有数字,而是字符串。
String s = "6430134080234080234080200000000";
您可以像这样格式化它:
String formatted = s.substring(0,3) + "," + s.substring(3,5) + "," ...
请注意,这仅在输入字符串的长度相同时才有效。