传递的参数多于格式字符串中实际使用的参数
FindBugs 在以下代码中向我显示“传递的参数多于格式字符串中实际使用的参数”消息:
String.format("00", bd.getHour())
bd.getHour()
返回一个 int< /代码>。
有人可以澄清这一点吗?我的目标是确保 1 位整数前面有 0 (1 ->01, 13->13...)。
在没有收到 FindBugs 消息的情况下实现此目的的正确方法是什么?
FindBugs gives me a 'More arguments are passed than are actually used in the format string' message on the following code:
String.format("00", bd.getHour())
bd.getHour()
returns an int
.
Can someone clarify this? My obective is to make sure that 1 digit ints are preceded by a 0 (1 ->01, 13->13...).
What is the right way to achieve this without getting a FindBugs message?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
String.format()
遵循 格式字符串,因此使用:因为您的行将只打印
00
并忽略添加的参数。String.format()
follows the rules of format string, so use:Because your line, will just print
00
and ignore the added parameter.