Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 463f633

Browse filesBrowse files
Create how-can-i-pad-an-integers-with-zeros-on-the-left.md
1 parent ae67302 commit 463f633
Copy full SHA for 463f633

File tree

Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 如何用0向左补齐一个整数?
2+
3+
## 问题
4+
5+
在Java中如何把一个整数转化为字符串并且用0向左补齐呢?
6+
7+
我基本上是希望把一个不大于9999的整数用0补齐 (比如说1=“0001”)。
8+
9+
## 解答
10+
11+
String.format("%05d", yournumber);
12+
13+
可以将一个五位数用0补齐。
14+
15+
16+
https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html
17+
18+
Stackoverflow链接:http://stackoverflow.com/questions/473282/how-can-i-pad-an-integers-with-zeros-on-the-left

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.